# Adding a Enable/Disable tag pen functionality to a Chart component

**URL:** <https://forum.inductiveautomation.com/t/adding-a-enable-disable-tag-pen-functionality-to-a-chart-component/32145>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [February 11, 2020, 8:34pm UTC](https://forum.inductiveautomation.com/t/adding-a-enable-disable-tag-pen-functionality-to-a-chart-component/32145 "2020-02-11T20:34:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdia](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdia/32/87599_2.png) [@mdia](https://forum.inductiveautomation.com/u/mdia)\
**Post date:** [February 11, 2020, 8:34pm UTC](https://forum.inductiveautomation.com/t/adding-a-enable-disable-tag-pen-functionality-to-a-chart-component/32145/1 "2020-02-11T20:34:35Z")

</div>

I have a chart component that is displaying data from two datasets having the same columns (24 each). I want to allow the user the ability to disable/enable a tag pen (which would basically be a column in this case) using a checkbox just like in the “Easy Chart” component. Any ideas on how to do that? Thanks

---

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [February 11, 2020, 11:45pm UTC](https://forum.inductiveautomation.com/t/adding-a-enable-disable-tag-pen-functionality-to-a-chart-component/32145/2 "2020-02-11T23:45:13Z")

</div>

You could make use of the `columnRearrange()` expression function to filter out certain columns from an input dataset, but the expression might not scale very well for a large number of columns.  
Alternatively, you could write a custom method on the Chart component which you then call using the `runScript()` expression function.

For example:

```auto
# Custom method on Chart component.
def filterDataset(data, *enCols):
	import system
	enabledCols = [0] # Always start with the t_stamp column
	for i in range(len(enCols)):
		if enCols[i]:
			enabledCols.append(i + 1)
	return system.dataset.filterColumns(data, enabledCols)

```

```auto
// Expression binding on Chart data property.
// First argument is the input dataset.
// Subsequent arguments is a boolean for each pen column indicating if that column is enabled.
// Example shows a 2-pen/column dataset.
runScript("self.filterDataset", 0,
	{Root Container.chartData},
	{Root Container.CheckBox_ShowPen1.selected},
	{Root Container.CheckBox_ShowPen2.selected}
)

```

Hope this helps give you an idea.
