# Easy Chart Show/Hide Pens

**URL:** <https://forum.inductiveautomation.com/t/easy-chart-show-hide-pens/9228>\
**Category:** Ignition\
**Created:** [October 24, 2014, 11:43pm UTC](https://forum.inductiveautomation.com/t/easy-chart-show-hide-pens/9228 "2014-10-24T23:43:19Z")\
**Posts on this page:** 1\
**Showing post:** 11

<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:** [June 22, 2021, 12:52pm UTC](https://forum.inductiveautomation.com/t/easy-chart-show-hide-pens/9228/11 "2021-06-22T12:52:21Z")

</div>

No worries.

You are having a scope issue. The variable `displaygroup` is not defined outside of the if and else statements.

I would change your code slightly to avoid this, something like:

```auto
# grab the tag pen datset for modification
chartdata = event.source.parent.getComponent('Easy Chart').tagPens

selgroup = {"HIDDEN":0,"ENABLED":1}
hidegroup = {"HIDDEN":1,"ENABLED":0}
newgroup = {"HIDDEN":0,"ENABLED":0}
# use button name as group name
selgroupname = event.source.text

row=0

# Check each new row in dataset
for row in range(chartdata.rowCount):
	groupname = chartdata.getValueAt(row,"GROUP_NAME")
	#assign new parameters based on selected group
	if groupname == selgroupname: #groupname is equal to button selected
		chartdata = system.dataset.updateRow(chartdata,row,selgroup)
	else: # uncommentsection to hide other groups
		chartdata = system.dataset.updateRow(chartdata,row,hidegroup)
# update tag pen dataset in chart		
event.source.parent.getComponent('Easy Chart').tagPens = chartdata
```

---

_[View the full topic](https://forum.inductiveautomation.com/t/easy-chart-show-hide-pens/9228)._
