Optimizing TCHart drawing in Delphi 7

久未见 提交于 2020-01-03 00:01:14

问题


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";


回答1:


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));



回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/4782560/optimizing-tchart-drawing-in-delphi-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!