Classic chart Y axis visible property

Can you set the Y axis of the chart visible scripting property like some other expamples you have posted like axis.setLowerBound(20)? I tried axis.setvisible(1) but that didn’t work. I want to hide and show the Y axis in scripting.

You can use the following:


The key is, event.source.parent.getComponent(“Chart”).getChart() returns a JFreeChart (org.jfree.chart.JFreeChart) object. Once you have that object, then you can navigate through the JFreeChart API from there. Here’s the API:

Thanks. It works. You provided a good explanination and usefull documentation.

I am trying to Implement this code by doing something like

chart = event.source.parent.getComponent("Compare")
if event.source.selected :


chart = event.source.parent.getComponent("Compare")
if event.source.selected :

Because event.source.parent.getComponent(“Compare”) = org.jfree.chart which then can be org.jfree.chart.axis.Axis(“MDR1”)

but it gives me an error as -

Traceback (most recent call last):

  File "<event:actionPerformed>", line 3, in <module>

AttributeError: '' object has no attribute 'axis'

Ignition v7.9.9 (b2018081621)
Java: Oracle Corporation 1.8.0_191

No, that would be a JComponent, either a ChartPanel (Classic chart) or a container of a ChartPanel (EasyChart). You have to drill down into the JComponent to find the JFreeChart object (traverse the nested components).

i am also looking for same thing… hide axis based on the condition

any one have solution for this?

@pturmel and @kaushik.shah @dkhayes117 u have any scripting idea for this?

As previously mentioned in the thread you have to drill down into the component to be able to access the methods to hide the axis. XYPlot (JFreeChart 1.5.3 API)

Below is an example of drilling down to the necessary level to hide an axis from a toggle button.

comp = event.source.parent.getComponent('Chart')
chart = comp.getChart()
plot = chart.getXYPlot()
axis = plot.getRangeAxis()
print "comp: %s, chart: %s, plot: %s, axis: %s" % (type(comp), type(chart), type(plot), type(axis))
if event.source.selected:

This prints

comp: <type 'com.inductiveautomation.factorypmi.application.components.PMIChart'>
chart: <type 'org.jfree.chart.JFreeChart'>
axis: <type 'org.jfree.chart.axis.NumberAxis'>

So getChart(), getXYPlot(), getRangeAxis() methods are drilling down into the different levels of the component.

getRangeAxis() is the y-axis, and getDomainAxis() is the x-axis.