# Having trouble adding pens to EastChart in script

**URL:** <https://forum.inductiveautomation.com/t/having-trouble-adding-pens-to-eastchart-in-script/14832>\
**Category:** Ignition\
**Created:** [July 19, 2017, 12:46pm UTC](https://forum.inductiveautomation.com/t/having-trouble-adding-pens-to-eastchart-in-script/14832 "2017-07-19T12:46:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivasa](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Srinivasa](https://forum.inductiveautomation.com/u/Srinivasa)\
**Post date:** [July 19, 2017, 12:46pm UTC](https://forum.inductiveautomation.com/t/having-trouble-adding-pens-to-eastchart-in-script/14832/1 "2017-07-19T12:46:16Z")

</div>

The following visionWindowOpened script clears the pens in the Easy Chart but fails to add pens:  
Can’t figure it out? Any help is appreciated…

**I have downloaded Click TO Graph.zip. Renamed to gwbk. When tried to restore, got the following error:**  
**Error writing to restore file: java.io.IOException: Can not retrieve file ‘backupinfo.xml’ from Gateway backup**

pyDataSet = system.dataset.toPyDataSet(easyChart.tagPens)  
index = 0  
for row in pyDataSet:  
try:  
easyChart.tagPens = system.dataset.deleteRow(easyChart.tagPens, index)  
except:  
print(“Exception while removing from East Chart in History window %”, sys.exc\_info()[1])

tagNames = [“Machine Code”]

tagPaths = ["[.]" + “Factory/” + selectedStation + “/MachineCode”]

num = 0  
for tag in tagPaths:  
try:  
row = list(pyDataSet[0])  
row[“NAME”] = tagNames[num]  
row[“TAG\_PATH”] = tagPaths[num]  
easyChart.tagPens = system.dataset.addRow(easyChart.tagPens, row)  
num = num + 1  
except:  
print(“Exception while adding new pen to East Chart in History window %”, sys.exc\_info()[1])

---

<div class="post-metadata">

**Author:** ![Paul.Scott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.scott/32/4578_2.png) [@Paul.Scott](https://forum.inductiveautomation.com/u/Paul.Scott)\
**Post date:** [July 19, 2017, 11:33pm UTC](https://forum.inductiveautomation.com/t/having-trouble-adding-pens-to-eastchart-in-script/14832/2 "2017-07-19T23:33:32Z")

</div>

I’m assuming the mention of Click To Graph is a separate issue, is that correct? Note that the Click To Graph is **not** a gateway backup: unzipping the file contains instructions on how to use the files within.

As for the script, it looks like the visionWindowOpened event is only triggering when the window is opened in the client, and not the designer. Are you testing this in the designer or client?

---

<div class="post-metadata">

**Author:** ![Srinivasa](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Srinivasa](https://forum.inductiveautomation.com/u/Srinivasa)\
**Post date:** [July 19, 2017, 11:50pm UTC](https://forum.inductiveautomation.com/t/having-trouble-adding-pens-to-eastchart-in-script/14832/3 "2017-07-19T23:50:00Z")

</div>

Thank for info on Click to Graph. I am testing by launching a client and not in the designer.

---

<div class="post-metadata">

**Author:** ![Paul.Scott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.scott/32/4578_2.png) [@Paul.Scott](https://forum.inductiveautomation.com/u/Paul.Scott)\
**Post date:** [July 20, 2017, 8:35pm UTC](https://forum.inductiveautomation.com/t/having-trouble-adding-pens-to-eastchart-in-script/14832/4 "2017-07-20T20:35:02Z")

</div>

When it fails, are you getting an error? You should see something in the console, if not an error box appearing when it fails. If it is actually clearing the pens, then there should be an error reporting which line it failed on.

Side note: the example you posted is a bit difficult to read since it lost the formatting/indentation. I could guess at it, but you could try posting your code again with the indentation: paste your code into the reply box, select the code, and click the Preformatted Text button at the top of the reply box (or wrap your code in triple backtick **`** characters

---

<div class="post-metadata">

**Author:** ![Srinivasa](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Srinivasa](https://forum.inductiveautomation.com/u/Srinivasa)\
**Post date:** [July 21, 2017, 1:54am UTC](https://forum.inductiveautomation.com/t/having-trouble-adding-pens-to-eastchart-in-script/14832/5 "2017-07-21T01:54:54Z")

</div>

Hi Scott,  
here is the formatted code. It won’t show any errors on console or won’t logs any messages “myLogger” on Gateway …  
Any help is appreciated.

```auto
# This script was generated automatically by the property set
# script builder. You may modify this script, but if you do,
# you will not be able to use the property set builder to update
# this script without overwriting your changes.

global system,app
import system
import sys
import app

logger = system.util.getLogger("myLogger")
logger.info("Hello, world.")

selectedStation = system.gui.getParentWindow(event).getComponentForPath('Root Container').SelectedStationName

easyChart = system.gui.getParentWindow(event).getComponentForPath('Root Container').getComponent('Easy Chart')

pyDataSet = system.dataset.toPyDataSet(easyChart.tagPens)
index = 0
for row in pyDataSet:
	try:
		easyChart.tagPens = system.dataset.deleteRow(easyChart.tagPens, index)
	except:
		logger.info("Exception while removing from East Chart in History window")

tagNames = ["Machine Code"]

tagPaths = ["[.]" + "Factory/" + selectedStation + "/MachineCode"]

num = 0
for tag in tagPaths:
	try:
		row = list(pyDataSet[0])
		row["NAME"] = tagNames[num]
		row["TAG_PATH"] = tagPaths[num]
		easyChart.tagPens = system.dataset.addRow(easyChart.tagPens, row)
		num = num + 1
	except:
		logger.info("Exception while adding new pen to East Chart in History window")
	

```
