# Trying to add plots to Time Series Chart with script

**URL:** <https://forum.inductiveautomation.com/t/trying-to-add-plots-to-time-series-chart-with-script/90570>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [May 17, 2024, 5:24pm UTC](https://forum.inductiveautomation.com/t/trying-to-add-plots-to-time-series-chart-with-script/90570 "2024-05-17T17:24:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_Wainwright](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@Kenneth\_Wainwright](https://forum.inductiveautomation.com/u/Kenneth_Wainwright)\
**Post date:** [May 17, 2024, 5:24pm UTC](https://forum.inductiveautomation.com/t/trying-to-add-plots-to-time-series-chart-with-script/90570/1 "2024-05-17T17:24:13Z")

</div>

I am attempting to add/remove plots on a TimeSeriesChart with a script that builds the plots array with a changescript on the parameter NumberValues.

The script works perfectly when in designer, but throws a type error exception when I try to append to the plots property in runtime.

Some help on this would be much appreciated, or an explanation of why it will not work.

Thanks!

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	numbervalues = self.params.NumberValues
	system.perspective.print("numbervalues" + str(numbervalues))
	plots = self.getChild("root").getChild("FlexContainer").getChild("TimeSeriesChart").props.plots
	system.perspective.print("beginninglen" + str(len(plots)))
	plottemps = self.custom.PlotTemplates
	plotslen = len(plots)
	plot1 = plottemps[0]
	plot2 = plottemps[1]
	plot3 = plottemps[2]
	
	while plotslen > 0:
		del plots[plotslen - 1]
		plotslen -= 1
	system.perspective.print("deletedlen" + str(len(plots)))

	while numbervalues > 0:
		system.perspective.print("loopvalues" + str(numbervalues))
		try:
			plots.append(plottemps[numbervalues - 1])
		except: 
			e = sys.exc_info()[0]
			system.perspective.print(e)
		numbervalues -=1
	system.perspective.print("rebuiltlen" + str(len(plots)))

```

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [May 17, 2024, 6:25pm UTC](https://forum.inductiveautomation.com/t/trying-to-add-plots-to-time-series-chart-with-script/90570/2 "2024-05-17T18:25:15Z")

</div>

Can you provide more info on the type error exception? Like is it happening in the try/except block near the end, and/or does it tell you what type(s) are causing the failure? Weird that it works only in the designer -- makes me think a certain value or parameter may have an improper persistence setting somewhere on that page.

---

<div class="post-metadata">

**Author:** ![Kenneth\_Wainwright](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@Kenneth\_Wainwright](https://forum.inductiveautomation.com/u/Kenneth_Wainwright)\
**Post date:** [May 17, 2024, 8:21pm UTC](https://forum.inductiveautomation.com/t/trying-to-add-plots-to-time-series-chart-with-script/90570/3 "2024-05-17T20:21:44Z")

</div>

Thanks for your quick reply!

In the course of getting more information for you, I solved the problem.

The full exception read as follows:

```python
(<type 'exceptions.TypeError'>, TypeError("unsupported operand type(s) for -: 'unicode' and 'int'",), <traceback object at 0x2>)

```

It looks like self.params.NumberValues was being read as a string; I wrapped an int() around it and everything works great now.

This doesn't explain why it worked in designer but not in the browser, which I would love to hear if anyone knows the answer
