Page 1 of 1

Fast Refresh of lines when adding points permanently

Posted: Mon Nov 10, 2008 8:59 am
by 7665917
Dear All

we are working on an application that displays permanently incoming
measurement data in a TChart component. Now we are facing one problem that
slows down our application.

Every time when a new value reaches the maximum of the time-axis TChart
resizes the measurement window and redraws all the lines. Since we are
adding live data all the time this is a very time consuming process.

Secondly we are refreshing the lines using 'line.refreshSeries()' and 'chart.repaint()'.
Is there a way to force TChart only to draw the added points instead of refreshing the Whole line?

Finally we would like to give an Offset to the chart so lines are not drawn to the borders of a chart.

Can you help us in these matters?

Yours scincerelly
Opus Software AG



Here's the code:

@Override
synchronized public void doRefresh(IDataProvider provider) throws EArgusException{
timeChart.getAxes().getLeft().setIncrement(Utils.getDateTimeStep(DateTimeStep.ONESECOND));
timeChart.getAxes().getLeft().getLabels().setDateTimeFormat("HH:mm:ss");
timeChart.getAxes().getLeft().getLabels().setExactDateTime(true);
timeChart.getLegend().setLegendStyle(LegendStyle.SERIES);

Collection<IChannel> channels = provider.getChannels();

for(IChannel chnl: channels) {
if(!(chnl.name().equals(IChannelNames.GPS_Date) || chnl.name().equals(IChannelNames.GPS_Time))){
HorizLine line = lineMap.get(chnl.name().toString());
if(line == null){
line = new HorizLine();
line.getYValues().setDateTime(true);
line.setTitle(chnl.name().toString());
channelUnit.put(chnl.name().toString(),chnl.axis());
lineMap.put(chnl.name().toString(), line);
}
if(timeChart.getSeries().contains(line)){
Iterator<IValue> iter = provider.getIterator(chnl.name());
IValue val = null;
while(iter.hasNext()){
val = iter.next();
if(val.getValue() != null && !val.getValue().equals(Double.NaN) && val.getTime() != null) {
line.add(val.getValue().doubleValue(),val.getTime().getTime());
}
}
line.refreshSeries();
}
}
}
timeChart.repaint();
}

Posted: Mon Nov 10, 2008 10:20 am
by narcis
Hi Chh,
Every time when a new value reaches the maximum of the time-axis TChart
resizes the measurement window and redraws all the lines. Since we are
adding live data all the time this is a very time consuming process.

Secondly we are refreshing the lines using 'line.refreshSeries()' and 'chart.repaint()'.
Is there a way to force TChart only to draw the added points instead of refreshing the Whole line?
I recommend you to try implementing your chart as explained in the Real-time Charting article here. There's no method for painting your series as requested but article's hints should help.

This article is written with TeeChart VCL version but most of it can also be applied to the Java version.
Finally we would like to give an Offset to the chart so lines are not drawn to the borders of a chart.
Yes, you can use this:

Code: Select all

        myChart.getAxes().getBottom().setMinimumOffset(10);
        myChart.getAxes().getBottom().setMaximumOffset(10);
        myChart.getAxes().getLeft().setMinimumOffset(10);
        myChart.getAxes().getLeft().setMaximumOffset(10);