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 = Color(255,230,0)
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…
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
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…
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.