Easy Chart select/unselect all pens

Hello,
Is here any scripting function or a property that allows a user to Select/Unselect all pens available on an easy chart?

I assume that by Select/Unselect you mean enable/disable. You would have to script it, but not to difficult to script.

Add a check box component to a window and in the actionPerformed add scripting to modify the tagPens dataset of the easy chart, setting the enable column appropriately for the sate of the check box.

2 Likes

As mentioned by Irose, just update the pens dataset via scripting. You have to have the pens configured for the chart first, then use loop through the pens dataset and use system.dataset.setValue(, , “ENABLED”, <0/1>) to manipulate the enabled property of the pen and load the this new dataset back into the tag pen property.

Something like this should work:

pens = chart.tagPens
for row in range(0, pens.rowCount):
	if enableAll == True:
		penUpdate = system.dataset.setValue(pens, row, "ENABLED", 1)
		chart.tagPens = penUpdate
   else:
		penUpdate = system.dataset.setValue(pens, row, "ENABLED", 0 )
		chart.tagPens = penUpdate

1 Like

One tweak you really should include is to only assign back to chart.tagPens once at the end. And there's no need for a separate penUpdate dataset.

True, but why stop there? Eliminate the if/else

Thanks for your help, it works fine. Here is the script I used:

pens=event.source.parent.getComponent('Easy Chart').pens
for row in range(pens.rowCount):
	if event.source.selected == 1:
		penUpdate = system.dataset.setValue(pens, row, "ENABLED", 1)
		pens = penUpdate
   	else:
		penUpdate = system.dataset.setValue(pens, row, "ENABLED", 0 )
		pens = penUpdate
event.source.parent.getComponent('Easy Chart').pens=pens

Try this:

pens=event.source.parent.getComponent('Easy Chart').pens
for row in range(pens.rowCount):
	if event.source.selected == 1:
		pens = system.dataset.setValue(pens, row, "ENABLED", 1)
   	else:
		pens = system.dataset.setValue(pens, row, "ENABLED", 0 )
event.source.parent.getComponent('Easy Chart').pens=pens
1 Like

This works as well. Thanks :+1:

This was perfect as I have charts preloaded with many tags on them using the solution by @pturmel Setting Default Pens in Easy Chart when Opening a window - #2 by pturmel

Since I have so many pens on the charts, I needed a way for the user to quickly unselect them all.
The only change I made for the script to work for me since I’m preloading the chart with Tag History pens is that I used .tagPens instead of .pens.

Thank you!