Jfree chart issue

I have been trying to create a custom chart. one of the main problem I am running into is defining the Plot !
I have a class object :

class LabTestChart():
	instance = None
	def __init__( self, chart ):
		self.chart = chart
		self.plotObj = chart.getPlot()
		# Each sub-plot is of type org.jfree.chart.plot.XYPlot
		# index 0 is the main part
		self.subPlots = self.plotObj.getSubplots()

and it gives me an error as :

AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'getSubplots'

	at org.python.core.Py.AttributeError(Py.java:173)
	at org.python.core.PyObject.noAttributeError(PyObject.java:930)
	at org.python.core.PyObject.object___getattribute__(PyObject.java:3692)
	at org.python.core.PyObject$object___getattribute___exposer.__call__(Unknown Source)
	at org.python.core.Deriveds.__findattr_ex__(Deriveds.java:59)
	at org.python.core.PyObjectDerived.__findattr_ex__(PyObjectDerived.java:983)
	at org.python.core.PyObject.__getattr__(PyObject.java:923)
	at org.python.pycode._pyx640.__init__$2(<module:shared.mixing.Reports.LabHistory>:55)
	at org.python.pycode._pyx640.call_function(<module:shared.mixing.Reports.LabHistory>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:301)

which is little weird as jfree chart has the Subplot object !


AttributeError: 'com.inductiveautomation.factorypmi.application.com' object

Print the type(self.plotObj) - it’s not a JFreeChart class, which is probably the problem.

Are you directly passing an Ignition component into your constructor? You need to go another level deeper to get the actual JFreeChart object - I believe it would be <ignition component reference>.getChart().getPlot()

1 Like

Got it working. Thanks

Was the getChart() part missing the issue, or…? (for posterity)

No, Since, it didn’t had more than 1 subPlot for that chart, PlotObj itself can be referenced to assign the variable to different properties of that subPlot. Basically, All I did is,

subPlots = self.plotObj

Hope it’s clear. Thanks