Checkbox pens with a "classic" chart

Hello,
I’m trying to get a chart (which is running a customized SQL query) to respond to checkboxes on the screen, so that the user can effectively turn certain curves on/off, like pens. Does anyone know how this can be accomplished?

I found an old thread that explains how to do it, but it’s now outdated:
Thread post
reference documentation

There is this “configureChart” extension function in the chart scripting tree with the following python code:
def configureChart(self, chart):
#doc-string

So, I created a checkbox with the following python in its scripting (under itemStateChanged):

chart = event.source.parent.getComponent(‘Curve Stats’)

chart.configureChart(event.source.parent.getComponent(‘CheckBox_Peak’), chart)

But then I get an error message (attached). :/

Any guidance on which part is incorrect or which approach I should try is much appreciated! :slight_smile:
Thanks

System:
Gateway ver 7.7.3


[quote=“liberty810”]I found an old thread that explains how to do it, but it’s now outdated:
Thread post[/quote]You say it’s outdated, but the .setSeriesEnabled() method still works in my v7.7.0 VM testbed.

[quote=“liberty810”]chart.configureChart(event.source.parent.getComponent('CheckBox_Peak'), chart)[/quote]I’m not sure what you are trying to make this do, but you can’t call the extension functions yourself. The system calls them when it needs to. Within the configure extension function, the self variable is the chart object. You can adjust it’s properties before it is displayed the first time, or when it is changed in a major way.
I think you should just create separate checkboxes for each pens in your query (that you want to be able to hide). Then on each checkbox, create a propertyChange event script like:if event.propertyName=='selected': chart = event.source.parent.getComponent("Curve Stats") chart.setSeriesEnabled("myDatasetName", "myColumnName", event.newValue)The “myDatasetName” would be the name of the chart dataset’s custom property, typically just “Data”.

1 Like