Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I speed up the TChart drawing?

437 views
Skip to first unread message

zwd

unread,
Dec 14, 1997, 3:00:00 AM12/14/97
to

hi, everyone

I use D3 c/s and TChart to analysis fibre test result, which consists of
16000 points.
I draw out these points using lineseries, and it worked OK.
But the drawing speed is too slow, about 5 minutes (P166/32M). When
drawing, my hard disk
sounds ga-ga. I think it is swapping memory.

I have read a tip somewhere that I can tell the points number to TChart,
which will reduce
the memory-allocating times. But I can not find the tip again.

How can I speed up the drawing? Where is the tip?

Any advice is appreciated.

Zhang Weidang
------------
BUAA, China

David Berneda

unread,
Dec 14, 1997, 3:00:00 AM12/14/97
to

Hi Zhang !
There are some important things to consider to speed up
TeeChart drawing.

-- The first one is to avoid using more points than pixels
the screen has, because the screen can only show one point
on each pixel. You can add averages to reduce the number of points.

-- The TFastLineSeries is much faster than TLineSeries because
it draws in 2D only.

-- There is a global variable called "TeeDefaultCapacity" you can set
at your form startup. This had more sense in Delphi 1 and 2 than in
D3, because D3 allocates memory much faster:

TeeDefaultCapacity:=16000;

-- See the tchartv3.doc manual in \delphi 3\teechart. There is
a section about speed.

-- You can test the drawing speed with this code, isolating the time
needed to add points:

procedure TForm1.BitBtn1Click(Sender: TObject);
Var StartTime,EndTime:Integer;
begin
StartTime := GetTickCount;
Chart1.Repaint;
EndTime:=GetTickCount;
ShowMessage('Time in milliseconds: '+IntToStr(EndTime-StartTime));
end;

-- Other suggestions are to turn off the legend, use a Pen.Width of 1, and
not use a background image.
Try the above code with different chart/series settings.

-- The Chart size (width x height) is directly proportional to the speed
time.

-- Windows NT4 is double fast than Windows95 or 95B.
256 colors might be faster than only 16 or 32768 or bigger.

-- Check the FastLine speed test form at \delphi 3\demos\teechart.

-- There is a Chart property you can try with your system. Depending
on the Chart size, the Windows version and the video card model you
can maybe get faster results:

Chart1.BufferedDisplay := False;

-- Try first a blank empty new project with a Chart and a FastLine series
and this line of code. It will isolate from the rest of your app.

procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(16000);
end;

-- Use the appropiate drivers for the video card. For example,
the Matrox driver is much faster than the original Windows "SVGA".

Best Regards !
David Berneda
http://www.teemach.com

zwd escribió en mensaje <349334...@buaa.edu.cn>...

zwd

unread,
Dec 17, 1997, 3:00:00 AM12/17/97
to

David Berneda wrote:
>
> Hi Zhang !
> There are some important things to consider to speed up
> TeeChart drawing.
>
Hi, David

Thank you for your assistance. With your advice, I have found the
problem. It is the TBlobStream which causes the memory swapping!

In my app, the fibre test data (about 32K) stored in sybase image field.
When I draw a lineseires, I get the image data, then create a
TBlobStream using
following code:
var
CurveData: TBlobStream;
i: integer
PointChar: Char;

.......
begin
CurveData := TBlobStream.Create(MyBlobField, bmRead);
for i:=0 to CurveData.Size do
begin
CruveData.Read(PointChar, 1);
LineSeires.AddXY(i, Byte(PointChar));
end;
end;

The swapping memory was caused by the CurveData.Read method. Whem I use
a TMemoryStream
to replace TBlobStream, it is all OK!

Now, I have another question. I draw the fibre test points using a
fastlineseries. When the
fasslineseries is zooming or panning, I want to draw a lineseries in
another TChart,
which is a skelton of the first line series, and using a rectangle in
second series to positon the
zooming or panning rect of the first lineseries. How can I draw a
skelton of the first lineseires?
How can I draw the first series's zoom rect on the skelton?

Thank you.

zwd
-----
BUAA, China.

0 new messages