i use teechart pro vcl for plot charts from input data.
i read data from comport and add points to TFastlineseries with this code :
var
a : integer;
b : double;
-----------------------------
With Dbchart1.Series[0] Do
Begin
Series0.AddXY(a, b, '', clTeeColor);
end;
i have very simple 2d or sometimes 3d colorfully graphs with more than 100000 points. but after 20000 points the rendering gets very slow and in some place it will be stop.
what can i do!? is there any algorithm for improve this situation?
Turn off drawing all the points.
Series0.DrawAllPoints := false;
From Real-time charting in TeeChart VCL:
TFastLineSeries introduces several properties for fast drawing
- The DrawAllPoints boolean property, default value True. Normally
chart size is limited to a fixed number of screen pixels. This means
that if, for example, you have 1.000.000 points, they will inevitably
"share" the same screen pixel coordinate (in horizontal, vertical or
both directions). Drawing an algorithm will then plot multiple points
with different real x,y coordinates at the same screen coordinate.
After multiple calls to drawing the algorithm and waste of cpu time
you'll end up with a single painted screen pixel. In this case a
reasonable thing to do is group the points with the same x screen
pixel coordinate and replace them with two points (group minimum and
maximum values). The end result will visually be the same as drawing
all the points in the group. But it will be a lot faster, especially
if there are lots of points per group. Setting DrawAllPoints to False
does precisely that : the internal algorithm processes data and draws
only non-repeated (group) points. Using this trick you can plot
millions of points in realtime with little fuss.
The PDF also mentions how to delete from a series in real time.
- Series Delete method. The Delete method now includes a second
parameter which controls how many points will be deleted from a
series. This allows fast delete of multiple points in a single call,
which is much faster than deleting multiple points using a loop.