Refreshing Classic Chart

Thanks for your input guys. I was able to refresh my chart configuration, specifically the Y Axis range, after my custom properties updated by running this script in another custom method on the root container.

	#Update Y Axis
	Chart = self.getComponent('Chart')
	axes = Chart.getYAxes()
	axis = axes.get('Default Y Axis')
	maxRange = max(self.max,self.setpointHigh)
	minRange = min(self.min,self.setpointLow)
	range = maxRange - minRange
	axis.setLowerBound(minRange - 0.1*range)
	axis.setUpperBound(maxRange + 0.1*range)
	Chart.setYAxes(axes)
	
	#Refresh Chart
	Chart.createChart()
	print "Chart has been updated after Std Dev value changed

This getter and setter for the Chart object was in my Chart’s “configureChart” extension function and because I’m not very familiar with python/object oriented programming I didn’t think I could just paste that code into another script. But you can, and that’s what I did. Works great. I also tried the script that Brian proposed above:

	chart = self.getComponent('Chart')
	chart.setDatasetEnabled("Data", False)
	chart.setDatasetEnabled("Data", True)

But for some reason that only reset my Y-axis about 50% of the time.
Thanks again!

1 Like