With the help of one of @pturmel's scripts to find the underlying chart, something like this in the propertyChange script of the Easy Chart.
For testing only. Break some of this out into project scripts for use in production.
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! """
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"
if event.propertyName == 'startDate' or event.propertyName == 'endDate':
component = event.source
src, chart = findJFChart(component)
dataIn = system.dataset.toPyDataSet(chart.getXYPlot().dataset.getDataSetForSeries(0))
startTime = dataIn[0][0]
kWseconds = 0.0
for prevRow, row in zip(dataIn, dataIn[1:]):
if row[1] == 0:
break
b1 = prevRow[1]
b2 = row[1]
h = system.date.secondsBetween(prevRow[0], row[0])
kWseconds += (b1+b2)/2*h
totalSeconds = system.date.secondsBetween(startTime, prevRow[0])
kWh = kWseconds / totalSeconds
# Write value to some other component
#event.source.parent.getComponent('Label').text = str(kWh)