# Easy Chart select/unselect all pens

**URL:** <https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652>\
**Category:** Ignition\
**Created:** [October 12, 2017, 1:37pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652 "2017-10-12T13:37:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [October 12, 2017, 1:37pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/1 "2017-10-12T13:37:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 12, 2017, 2:00pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/2 "2017-10-12T14:00:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [October 12, 2017, 2:34pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/3 "2017-10-12T14:34:40Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 12, 2017, 6:22pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/4 "2017-10-12T18:22:06Z")

</div>

> [@Paullys50](#):
>
> Something like this should work

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.

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [October 12, 2017, 7:01pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/5 "2017-10-12T19:01:57Z")

</div>

> [@pturmel](#):
>
> One tweak you really should include

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

---

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [October 13, 2017, 7:24am UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/6 "2017-10-13T07:24:46Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 13, 2017, 12:34pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/7 "2017-10-13T12:34:18Z")

</div>

> [@pascal](#):
>
> Here is the script I used

Try this:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [October 16, 2017, 6:45am UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/8 "2017-10-16T06:45:04Z")

</div>

This works as well. Thanks 👍

---

<div class="post-metadata">

**Author:** ![Richard\_Tryon](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@Richard\_Tryon](https://forum.inductiveautomation.com/u/Richard_Tryon)\
**Post date:** [September 13, 2022, 12:41pm UTC](https://forum.inductiveautomation.com/t/easy-chart-select-unselect-all-pens/15652/9 "2022-09-13T12:41:03Z")

</div>

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](https://forum.inductiveautomation.com/t/setting-default-pens-in-easy-chart-when-opening-a-window/16603/2)

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!
