Easy Chart: Accessing the Datasets Being Rendered

Good morning JJ,

I can help you find the JFreeChart, but I think you are going to be disappointed: the chart doesn’t contain normal datasets. The EasyChart munges large datasets before loading them, so the data you’ll be able to obtain may not be complete. With that caveat, here’s how I find the JFreeChart when I need it:

def findJFChart(src): """IA's EasyChart and XYPlot components have their JFreeChart objects at different positions in the Container/Component hierarchy. This helper function scans the hierarchy, given a container or component as a starting point, and returns a tuple containing the parent JFreeChartPanel and the targeted JFreeChart. Note: The hierarchy is searched depth-first! """ from app.scriptmodule import findJFChart try: return (src, src.chart) except: pass try: for x in range(src.componentCount): try: return findJFChart(src.getComponent(x)) except: pass except: pass raise ValueError, "Unable to Find a JFreeChart Instance"
The code makes one major assumption: that the first property named “chart” that it encounters is the desired JFreeChart. If that isn’t sufficient, you would need to add type-checking of that property.

Hope this helps!

Phil

1 Like