Easy Chart; dynamic number of plots based on tags on Easy Chart not working

I have an easy chart setup with a pressure, temperature and level. I want to create a template which enables the use of a template repeater which the user can use a dropdown menu to pick the plot number to display the data. I have the template working using a script and its based on the number of tags in the easy chart. When I use the repeater it is not updating correctly.

Here is my template:

Here is the dataset view

Here is the binding in the dataset:

numPlots is a template parameter

Here is the script:
image

On a screen I have the template repeater using the Plot DropDown template

My inclination is to get rid of the runscript expression binding, and just use a property change script on the template itself to update the dropdown.

Something like:

# Run at initialization and any time the template repeater changes the numPlots property
if event.propertyName in ['componentRunning', 'numPlots']:
	headers = ['value', 'label']
	data = [[index + 1, 'Plot {}'.format(index + 1)] for index in xrange(event.source.numPlots)]
	event.source.getComponent('Dropdown').data = system.dataset.toDataSet(headers, data)

Then, assuming the template repeater is in dataset mode, a propertyChange script on the easy chart could drive the numPlots and tagLabel parameters:

# Run at initialization and any time tags are added or removed
if event.propertyName in ['componentRunning', 'tagPens']:
	# Allow for each tag pen to potentially have its own subplot, and put the name of the pen in the template's labelText property
	tagPens = event.source.tagPens
	templateParameters = system.dataset.toDataSet(['numPlots', 'tagLabel'], [[tagPens.rowCount, tagPens.getValueAt(index, 'NAME')] for index in xrange(tagPens.rowCount)])
	event.source.parent.getComponent('Template Repeater').templateParams = templateParameters

Note that the component running event doesn't occur in the designer unless the designer is already in preview mode when the window is opened.

1 Like