# Button to remove all pens from easy chart

**URL:** <https://forum.inductiveautomation.com/t/button-to-remove-all-pens-from-easy-chart/68964>\
**Category:** Ignition\
**Created:** [January 24, 2023, 1:39pm UTC](https://forum.inductiveautomation.com/t/button-to-remove-all-pens-from-easy-chart/68964 "2023-01-24T13:39:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Gregory](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Robert\_Gregory](https://forum.inductiveautomation.com/u/Robert_Gregory)\
**Post date:** [January 24, 2023, 1:39pm UTC](https://forum.inductiveautomation.com/t/button-to-remove-all-pens-from-easy-chart/68964/1 "2023-01-24T13:39:34Z")

</div>

I am trying to make a trend window on my ignition dashboard. I am using the tag browser to pull pens into the chart, but I do not like the way you have to natively remove the pens with the "x". I want to disable pen control, and add a button that will clear all the pens off the chart.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/b/9b6daa8df36735d36dea2ceadd3d1f578da92581.png)

---

<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:** [January 24, 2023, 1:55pm UTC](https://forum.inductiveautomation.com/t/button-to-remove-all-pens-from-easy-chart/68964/2 "2023-01-24T13:55:13Z")

</div>

Consider using Legends instead of the pen control subwindow (it can be disabled).

---

<div class="post-metadata">

**Author:** ![Robert\_Gregory](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Robert\_Gregory](https://forum.inductiveautomation.com/u/Robert_Gregory)\
**Post date:** [January 24, 2023, 2:48pm UTC](https://forum.inductiveautomation.com/t/button-to-remove-all-pens-from-easy-chart/68964/3 "2023-01-24T14:48:27Z")

</div>

I am using legends, but there is no way to remove pens from the trend with legends.

---

<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:** [January 24, 2023, 3:10pm UTC](https://forum.inductiveautomation.com/t/button-to-remove-all-pens-from-easy-chart/68964/4 "2023-01-24T15:10:38Z")

</div>

Yes, you can remove the row from the `tagPens` or `pens` dataset property of the EasyChart. That removes the pen. (Yes, you will need a button of your own to script it.)

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 25, 2023, 8:08pm UTC](https://forum.inductiveautomation.com/t/button-to-remove-all-pens-from-easy-chart/68964/5 "2023-01-25T20:08:18Z")

</div>

I often group the pens and have multiple buttons along the top that show/hide the different groups using scripting. Something along the lines of

```auto
#grab all pens from the chart. this will be edited and then stored back to the chart
data = event.source.parent.getComponent('Easy Chart').pens

#define show/hide states
showGroup = {"HIDDEN":0, 'ENABLED':0}
hideGroup = {"HIDDEN":1, 'ENABLED':0}
newGroup = {"HIDDEN":0, 'ENABLED':0}

#selected group matches button text
selectedGroupName = event.source.text

#custom property
shown = event.source.showGroup

#initialize row at row 0
row = 0

#if group is currently being shown
if shown:
	#for each pen in the chart
	for row in range(data.rowCount):
		#get group name for pen
		groupName = data.getValueAt(row,"GROUP_NAME")
		#if group name matches button text
		if groupName == selectedGroupName:
			#hide group
			data = system.dataset.updateRow(data,row,hideGroup)
			#set custom property to false (group is hidden)
			event.source.showGroup = False
#group is currently being hidden
else:
	#for each pen in the chart
	for row in range(data.rowCount):
		#get group name for pen
		groupName = data.getValueAt(row,"GROUP_NAME")
		#if group name matches button text
		if groupName == selectedGroupName:
			#show group
			data = system.dataset.updateRow(data,row,showGroup)
			#set custom property to true (group is shown)
			event.source.showGroup = True

#write the re-configured pens dataset back to the chart
event.source.parent.getComponent('Easy Chart').pens = data

```

In this example the button text matches the group name.
