# PowerChart Pen Property Change Script

**URL:** <https://forum.inductiveautomation.com/t/powerchart-pen-property-change-script/116351>\
**Category:** Ignition\
**Tags:** perspective, ignition83\
**Created:** [July 10, 2026, 3:00pm UTC](https://forum.inductiveautomation.com/t/powerchart-pen-property-change-script/116351 "2026-07-10T15:00:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshua.edwards.navy](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@joshua.edwards.navy](https://forum.inductiveautomation.com/u/joshua.edwards.navy)\
**Post date:** [July 10, 2026, 3:00pm UTC](https://forum.inductiveautomation.com/t/powerchart-pen-property-change-script/116351/1 "2026-07-10T15:00:48Z")

</div>

I was trying to make a Property Change Script for pens in a PowerChart. Here's my code:

> **Code**
>
> ```python
> def valueChanged(self, previousValue, currentValue, origin, missedEvents):
> pens = list(self.props.pens)
> changed = False
> 
> for pen in pens:
> # Get name of pen
> name = pen.get("name", "").lower()
> 
> # If it contains open or close then desired axis is "Valves" else "Default"
> desiredAxis = "Valves" if (
> "open" in name or
> "close" in name
> ) else "Default"
> 
> # If the axis isn't the desired axis then change to desired axis
> if pen.get("axis") != desiredAxis:
> system.perspective.print("Changing axis because it's not desired: " + str(pen["axis"]))
> pen["axis"] = desiredAxis
> changed = True
> 
> if changed:
> self.props.pens = pens
> 
> ```

I have 2 setup axes. "Default" and "Valves". The script seems to do it's job perfectly. The problem seems to be that the PowerChart component is resetting the pen axis to an empty string. So it will switch between "" and one of the 2 desired setup axes. Is there some way to get PowerChart to stop changing the axis of a pen once I set it? I'm guessing it's a React State. If I could change it's state via code that would work too.

---

<div class="post-metadata">

**Author:** ![joshua.edwards.navy](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@joshua.edwards.navy](https://forum.inductiveautomation.com/u/joshua.edwards.navy)\
**Post date:** [July 30, 2026, 5:37pm UTC](https://forum.inductiveautomation.com/t/powerchart-pen-property-change-script/116351/2 "2026-07-30T17:37:01Z")

</div>

I finally figured out how to do this.

> **Code**
>
> ```python
> if origin == 'Script' or not currentValue.value:
> return
> 	
> pens = list(self.props.pens)
> i = 0
> 	
> for pen in pens:
> name = pen.get("name", "").lower()
> system.perspective.print("In pen: " + str(name))
> 	
> desiredAxis = "Valves" if (
> "open" in name or
> "close" in name
> ) else "Default"
> 	
> if pen.get("axis") != desiredAxis:
> self.props.pens[i].axis = desiredAxis
> if ("open" in name):
> self.props.pens[i].display.type = "area"
> #self.props.pens[i].display.styles.normal.fill.color = "#008000" #green
> self.props.pens[i].display.styles.normal.fill.opacity = 0.65
> elif ("close" in name):
> self.props.pens[i].display.type = "area"
> #self.props.pens[i].display.styles.normal.fill.color = "#FF0000" #red
> self.props.pens[i].display.styles.normal.fill.opacity = 0.65
> 	    
> i = i + 1
> 
> ```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [July 31, 2026, 6:14am UTC](https://forum.inductiveautomation.com/t/powerchart-pen-property-change-script/116351/3 "2026-07-31T06:14:27Z")

</div>

> [@joshua.edwards.navy](#):
>
> `for pen in pens:`

> [@joshua.edwards.navy](#):
>
> `i = i + 1`

FYI, instead of defining and updating `i` yourself, just use enumerate which does this for you

```python
for i, pen in enumerate(pens):

```

---

<div class="post-metadata">

**Author:** ![joshua.edwards.navy](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@joshua.edwards.navy](https://forum.inductiveautomation.com/u/joshua.edwards.navy)\
**Post date:** [July 31, 2026, 2:11pm UTC](https://forum.inductiveautomation.com/t/powerchart-pen-property-change-script/116351/4 "2026-07-31T14:11:35Z")

</div>

I figured there was a python function that would do this.
