Change series color of chart from script

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?

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.yellow,,,, Color.magenta, Color.gray] event.source.parent.getComponent('Chart').seriesColors = colors

1 Like

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’

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.yellow,,,, 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.

1 Like

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.

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

Your right, James.