# How would I add a pen json to a power chart

**URL:** <https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting\
**Created:** [December 15, 2021, 11:17pm UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175 "2021-12-15T23:17:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [December 15, 2021, 11:17pm UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175/1 "2021-12-15T23:17:48Z")

</div>

So I copy and pasted the json from on of the pens and modded it so i can add a new pen through script. It’s not working, python is complaining about true. Am I going about this the correct way?Thanks, Jake

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 15, 2021, 11:21pm UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175/2 "2021-12-15T23:21:41Z")

</div>

JSON, while _similar_ to valid Python code, is not quite there.  
One of the big differences is that Javascript (and therefore JSON) use `true`, `false`, and `null` as literals.  
If you’re writing this out as literals, you can just do a manual/automated string replacement, e.g. `true` → `True`, `null` → `None`.

There may be other issues with string escaping/quoting, etc, but that’s probably a start.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [December 16, 2021, 6:08pm UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175/3 "2021-12-16T18:08:14Z")

</div>

That got it going. Now the only problem is I can’t get it to actual show up. When I click on the config of the power chart they are there, just not displaying them. I tried a refreshBindings with no luck.Thanks, jake

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [December 17, 2021, 3:26pm UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175/4 "2021-12-17T15:26:48Z")

</div>

Anyone else encounter this. Seems odd it’s not displaying, but it shows it’s there.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [December 17, 2021, 4:40pm UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175/5 "2021-12-17T16:40:40Z")

</div>

nevermind, I’m an idiot, there were some params so those weren’t getting replaced, all is well, thank you all

---

<div class="post-metadata">

**Author:** ![arun1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arun1/32/79753_2.png) [@arun1](https://forum.inductiveautomation.com/u/arun1)\
**Post date:** [January 8, 2022, 7:20am UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175/6 "2022-01-08T07:20:03Z")

</div>

Hi @codersmurf , I am facing the exact same issue. Which params did you write using script? I am using an Expression Binding with a Script Transform to write to the “pens” property of a PowerChart. Is there any other params that I need to be writing to or some data format issue? If I select a pen using the built-in tag browser and just right click to duplicate pens[0] then edit the tagPath and pen name then that works but not when I write from a script!  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/56675b07ade9bb91525892038711e74bd38579ac.png)

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [January 10, 2022, 1:37am UTC](https://forum.inductiveautomation.com/t/how-would-i-add-a-pen-json-to-a-power-chart/54175/7 "2022-01-10T01:37:10Z")

</div>

The problem happened with a db arc issue, the dec 2021 table was dropped instead of 2020. Once I restored the table all was well.Thx, jake
