Dynamic columnRearrange - Sync Table with EasyChart

Hi All,

EDIT: In writing this post, I determined the answer to my own question. Not regarding the columnRearrange, but regarding the use of the PropertyChange events.


I have an EasyChart which dynamically changes between Realtime Mode and Historical Mode based on the state of the current batch. Live data when the batch is running, historical data when in-between batches. All data is coming from the Tag Historian.

I have a table which I would like to link to the EasyChart such that each selected Pen is represented by a column in the table, and the table displays data within the current time-window of the EasyChart.

I have been able to sync the displayed columns to the selected Pens, but not in a way that also allows the table to update in real time when the EasyChart is in Realtime Mode.

Here are the details:

  1. EasyChart
  • Chart Mode dynamically set by Expression Binding to match the batch state

  • Start Date and Historical Outer Range Start set by Expression Binding to the batch start time

  • End Date and Historical Outer Range End set by Expression Binding to the batch end time

  • Tag Pens is hard coded with appropriate tags

  1. Dataset dataView
  • Custom Property on the window’s Root Container

  • Value set by Tag History Binding

  • All Tag Pens are represented in this query

  • Start Date Binding and End Date Binding are bound to EasyChart Start Date and End Date

  • Date Range is set to Historical

  • Polling Mode is set to Off

  1. String selectedPens
  • Custom Property on Window’s Root Container

  • Populated by PropertyChange script on the EasyChart:

if event.propertyName == 'tagPens':
	data = system.dataset.toPyDataSet(event.source.tagPens)
	columnNames = ['t_stamp']
	for row in data:
		if row['ENABLED']:
			path = row['TAG_PATH']
			i = path.rfind('/') + 1
			tag = path[i:]
			columnNames.append(tag)
        event.source.parent.selectedPens = columnNames
  1. The last step is to create a dataset for the table by filtering the dataView dataset on the list columnNames.

Ideally, I want to bind the the table’s data property to something like this expression:

columnRearrange(dataView, [columnNames])

That in itself does not work, and I’m not strong with the Expression Language yet - so I thought I would ask for help.

A different solution is to use EasyChart’s PropertyChange script to parse the selected Pens and create the table’s dataset at the same time. I would then let the script also run on change of StartDate.

if event.propertyName == 'tagPens' or event.propertyName == 'startDate':
	data = system.dataset.toPyDataSet(event.source.tagPens)
	columnNames = ['t_stamp']
	for row in data:
		if row['ENABLED']:
			path = row['TAG_PATH']
			i = path.rfind('/') + 1
			tag = path[i:]
			columnNames.append(tag)

	data = system.dataset.toPyDataSet(event.source.parent.dataView)
	newData = []
	for row in data:
		newRow = []
		for c in columnNames:
			try:
				newRow.append(row[c])
			except IndexError:
				pass
		newData.append(newRow)
	columnNames[0] = 'Time'
	event.source.parent.getComponent('tbl data').data = system.dataset.toDataSet(columnNames,newData)

My concern is that I will have 10 of these Chart/Table pairs per client, and potentially 30 clients active at the same time. This solution means I will unnecessarily parse the enabled Pens every time a Chart updates in Live Mode. Should I be concerned about that use of resources, or is it so small as to be moot?

Thank you for your time!