Ad Hoc Table

It’s easy to make an ad hoc chart in a client using a tag browse tree and an easy chart which allows users to drag/drop tags onto the chart to create a customizable trend, but it’s not so easy to create an ad hoc table. It took me a while to sort out how to do this with a table (in conjunction with an easy chart) so I figured I would post it here.

Script on property change of easy chart:

[code]if event.propertyName == “tagPens” or “startDate” or “endDate”:

paths = event.source.parent.getComponent('Table').paths
if paths != '':

	paths = paths.split(",")
	startDate = event.source.startDate
	endDate = event.source.endDate
	data = system.tag.queryTagHistory(paths, startDate, endDate)
	event.source.parent.getComponent('Table').data = data[/code]

binding of “paths” custom property of Table:

groupConcat({Root Container.Easy Chart.tagPens}, "TAG_PATH", ",")

Please post any improvement suggestions. i.e. a method not requiring the external groupConcat expression.

1 Like

You can loop through the tagPens dataset directly:if event.propertyName == "tagPens" or "startDate" or "endDate": tpens = event.source.tagPens paths = [tpens.getValueAt(r, 'TAG_PATH') for r in range(tpens.rowCount)] if paths: data = system.tag.queryTagHistory(paths, event.source.startDate, event.source.endDate) event.source.parent.getComponent('Table').data = dataI also tend to omit temporary variables like your startDate/endDate when they’re only used once.

Hey thanks y’all, this works great.

Convenient pro tip: it still works even if you layer the table in front of the chart in the window, so you can make it look like there is no chart present to the user.