# Change series color of chart from script

**URL:** <https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558>\
**Category:** Ignition\
**Created:** [November 4, 2011, 4:14pm UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558 "2011-11-04T16:14:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chris](https://forum.inductiveautomation.com/u/chris)\
**Post date:** [November 4, 2011, 4:14pm UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558/1 "2011-11-04T16:14:22Z")

</div>

Hello, is it possible to change the series colors of a Chart object from a script? ie. a way to control the colors of the plotted data from a script?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 4, 2011, 4:41pm UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558/2 "2011-11-04T16:41:30Z")

</div>

Yes, the series color property is just a color array. Here is how you can set it from a button:`from java.awt import Color
colors = [Color.green, Color.yellow, Color.red, Color.blue, Color.orange, Color.magenta, Color.gray]
event.source.parent.getComponent('Chart').seriesColors = colors`

---

<div class="post-metadata">

**Author:** ![chris](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chris](https://forum.inductiveautomation.com/u/chris)\
**Post date:** [November 8, 2011, 4:57pm UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558/3 "2011-11-08T16:57:03Z")

</div>

I seem to be missing something, perhaps the identifier for the dataset or something. I’m getting the following error when trying to recieve the current set of colors:

AttributeError: instance of ‘com.inductiveautomation.factorypmi.application.components.PMIChart’ has no attribute ‘seriesColors’

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 9, 2011, 1:28am UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558/4 "2011-11-09T01:28:02Z")

</div>

I am referring to the bar chart component since it has a property called Series Colors. The classic chart doesn’t expose the series colors as a property. You can use the following code for your classic chart:`from java.awt import Color
colors = [Color.green, Color.yellow, Color.red, Color.blue, Color.orange, Color.magenta, Color.gray]
chart = event.source.parent.getComponent('Chart')
chart.getDynamicProps().get("Data").getRenderer().setSeriesColors(colors)
chart.createChart()`Just replace the “Data” with your dataset you want to change the series colors on.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 10, 2013, 1:46pm UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558/5 "2013-05-10T13:46:16Z")

</div>

I am running Ignition 7.5.5 and using your script for changing seriesColor on a bar graph component results in an error saying ‘seriesColors’ is no attribute.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [May 10, 2013, 3:43pm UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558/6 "2013-05-10T15:43:13Z")

</div>

It should work, are you sure you’re getting back the correct bar chart component when using getComponent()?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 13, 2013, 12:35pm UTC](https://forum.inductiveautomation.com/t/change-series-color-of-chart-from-script/3558/7 "2013-05-13T12:35:34Z")

</div>

Your right, James.  
Thanks.
