Adding a Enable/Disable tag pen functionality to a Chart component

I have a chart component that is displaying data from two datasets having the same columns (24 each). I want to allow the user the ability to disable/enable a tag pen (which would basically be a column in this case) using a checkbox just like in the “Easy Chart” component. Any ideas on how to do that? Thanks

You could make use of the columnRearrange() expression function to filter out certain columns from an input dataset, but the expression might not scale very well for a large number of columns.
Alternatively, you could write a custom method on the Chart component which you then call using the runScript() expression function.

For example:

# Custom method on Chart component.
def filterDataset(data, *enCols):
	import system
	enabledCols = [0] # Always start with the t_stamp column
	for i in range(len(enCols)):
		if enCols[i]:
			enabledCols.append(i + 1)
	return system.dataset.filterColumns(data, enabledCols)
// Expression binding on Chart data property.
// First argument is the input dataset.
// Subsequent arguments is a boolean for each pen column indicating if that column is enabled.
// Example shows a 2-pen/column dataset.
runScript("self.filterDataset", 0,
	{Root Container.chartData},
	{Root Container.CheckBox_ShowPen1.selected},
	{Root Container.CheckBox_ShowPen2.selected}
)

Hope this helps give you an idea.

1 Like