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