Chart renderer not working

I am trying to change the pen colors on a normal XY chart using the following code…

from java.awt import Color

chart = event.source.parent.getComponent('chart1')
colors = chart.getDynamicProps().get("ranges").getRenderer().getSeriesColors()
colors[0] = Color(255,230,0)
chart.getDynamicProps().get("ranges").getRenderer().setSeriesColors(colors)

I get the following error…

File “”, line 22, in configureChart
NameError: global name ‘event’ is not defined

Not sure what is going on…

there is only one data series of data…

Thank You

configureChart isn’t an event. So it doesn’t have an event variable. Look at the top line to see the arguments passed in. Construct your code with those. For example, use self instead of event.source.

Thanks! I thought I tried that but will try again!

I must be missing something above my Ignition knowlege!

the args passed in are self and chart…

simply replacing event.source with self does not work…

assuming self is the object,

colors = self.getDynamicProps().get(“ranges”).getRenderer().getSeriesColors()

doesnt work either…both die with the same error, “Nonetype has no attribute renderer”

Still at a loss…

You’ve cut and pasted code that doesn’t seem to be for an XY Chart (classic chart in XY Plot mode). (A button with some customized chart as a sibling, it seems.) The getDynamicProps("ranges") looks suspicious/custom. The only dynamic props in the classic chart are the data series.

Hmmm…I got the code from the forum…dated back to 2013…anyhow,
is there a way to dynamically change a series color on an xy chart?

I didn’t want to just ask without demonstrating that I put some effort into it…:wink:

Thanks

Almost certainly. I just haven’t done exactly that, so have no code to supply. The comment in the configureChart() extension function is your next step: dig into the JFreeChart library.

Thanks!