Min Max & Average on Click To Graph

I’m using the click to graph window to display trends and our customer now wants to be able to click a button on the page that will will pop up a window displaying the min, max, average and total (if its a flow signal) for the currently enabled signals on the chart.
I was wondering if there is a simple way to do this?

Not simple, no.

If you want precise data, you should query the database or historian and let it compute the stats. May take longer, but you don’t have to consider the loss of detail in a display-optimized dataset.

Otherwise, you can dig into the actual display data via the chart’s nested JFreeChart objects. The XYPlot object in particular. First, see this post.

In your button’s actionPerformed event, retrieve the XYPlot and iterate through its data:

[code]# Assuming the button and EasyChart are siblings
easychart = event.source.parent.getComponent(“Chart”)

Retrieve the ChartPanel and JFreeChart

panel, jfc = shared.charting.findJFChart(easychart)

Get the plot

plot = jfc.getXYPlot()

Iterate through the data

for idx in range(plot.getDatasetCount()):
# These are XYDatasets from the jfreechart kit, not Ignition datasets
data = plot.getDataset(idx)
[/code]At this point, you’ll want to look in the JFreeChart documentation, especially the XYDataset.

Thanks for the reply.
I have done a script that queries the historian for the data between the two times selected, but as you say it seems to take anything from a few seconds to possibly over a minute depending on the number of signals displayed and the length of time.
But maybe I will just have to live with the delay, as I think your point about the loss of detail would probably raise more questions when the graph is zoomed in and a different value is received.

That kind of delay in a relational database generally means you don’t have your indexes set up properly.