Fast Refresh of lines when adding points permanently
Posted: Mon Nov 10, 2008 8:59 am
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();
}
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();
}