Optimizing TCHart drawing in Delphi 7

2019-06-08 09:01发布

My previous question had some great input, but it didn't work for me because my problem seems to be Delphi 7 related.

I have a chart with a single series (TFastLineSeries) and 3,600 datapoints which is taking up to 45 seconds to draw. Others have said that it should be lightning fast, so who can help, bearing in mind that I am using Delphi 7 and the standard TChart component.

I suspect that instead of calling AddXY() 3,600 times I should be preparing the data first, then adding it all at once.


Update: in D7 the AddXy() function signature is function AddXY(Const AXValue, AYValue: Double; Const AXLabel: String; AColor: TColor) : Longint; wheretimeLabelis a string representing MM:SS. But what value should I be passing for

and I cam calling it with `Chart1.Series[0].AddXY(Chart1.Series[0].Count, codValue, timeLabel, clRed


btw, I have coded Chart1.Series[0].XValues.DateTime := True; Chart1.BottomAxis.DateTimeFormat := 'nn:ss'; //'hh' or 'nn' or 'ss' as you wish, e.g. Chart1.BottomAxis.DateTimeFormat:="dd/mm/yyyy hh:mm";

3条回答
ゆ 、 Hurt°
2楼-- · 2019-06-08 09:45

This may help you from the developer of TeeChart.... Fast line drawing with TeeChart

查看更多
何必那么认真
3楼-- · 2019-06-08 09:46

Maybe the way you are generating the values to put in the chart is the bottleneck?

On Delphi 2010, I measured the following code to take less than 1/10 second:

var
  I: Integer;
begin
  for I := 0 to 3000 - 1 do
    Series1.AddXY(Random(1000), Random(100));
查看更多
迷人小祖宗
4楼-- · 2019-06-08 09:56

Btw: It can also speed up the drawing to set Chart1.AutoRepaint to false before you add your values and set if back to true afterwards

查看更多
登录 后发表回答