Hide the grid-line of bar chart in python script

I want to know how to hide the grid-line of bar chart in python script.
I start with .getChart().getPlot() but I don’t know how to access gridline color.
barchart= event.source
plot = barchart.getChart().getPlot()

You can set visibility with the following.

barChart = event.source
plot = barChart.getChart().getPlot()
plot.setRangeGridlinesVisible(0)
1 Like

Thanks schenk.
Could you tell me how to change the axis tick color?
Every time the value of bar chart change, it refresh itselft, the gridline show and hide again. Is it possible to disable this behavior?

Could you tell me how did you find this information?

The axis tick color can be changed within the Property Editor

You can find information about all of the classes here:
http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/index.html

If you need to find the type of object or its methods/fields, you can put this code in a button on the screen. It will output the info to the console in the designer.

comp = event.source.parent.getComponent('componentName')
print type(comp) # Prints the component type. You can then find this in the above link.
print dir(comp) # Prints all fields and methods for the component.

They only change label not the gray line. As you see there is a gray line beside axis value.

plot.setOutlinePaint(None)

1 Like

plot.setOutlinePaint(None)
not working still there.

That line can be removed with this:

plot.getRangeAxis().setAxisLineVisible(0)

plot.getRangeAxis().setAxisLineVisible(0)
No luck the gray border is still remain :sweat:

How/where are you running this code?

In window open event and bar chart property change event.
I put it in property change event because every time the value changes the bar back to its default configuration, gridline come back to visible!!

barChart = event.source
plot = barChart.getChart().getPlot()
plot.setRangeGridlinesVisible(0)
plot.getRangeAxis().setAxisLineVisible(0)
the grid hide but the gray outline is still there.

FYI, if you use triple back-ticks before and after your code, it will format nicely.

You may need to include this also

I was able to get this to work in a client:

if event.propertyName in ['data', 'componentRunning']:
	plot = event.source.getChart().getPlot()
	range = plot.getRangeAxis()
	domain = plot.getDomainAxis()

	plot.setRangeGridlinesVisible(0)
	plot.setOutlinePaint(None)
	range.setAxisLineVisible(0)		# Remove left line
	domain.setAxisLineVisible(0)	# Remove bottom line
1 Like

Thank you very much schenk.
I just see some some annoying refreshing every time input data change for bar chart. It causes every thing back to its default and set again. (fast blink in gridlines, axis hide/show).
Is there a way to disable refreshing of Bar component?

I would switch over to the regular chart component and set it to the category Plot.

like bar chart in regular chart doesn’t have gridlines color property so I need again write those code and it blink each time the data changes.

In a regular chart you can put your adjustments in the configureChart method (with some edits) which is run before the first paint event.

2 Likes