Fast Refresh of lines when adding points permanently

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
MHA
Newbie
Newbie
Posts: 6
Joined: Wed Oct 03, 2007 12:00 am

Fast Refresh of lines when adding points permanently

Post by MHA » 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();
}

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Nov 10, 2008 10:20 am

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);
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply