1

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

Community
  • 1
  • 1
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551

3 Answers3

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));
Dan Bartlett
  • 826
  • 7
  • 8
  • +1 Thanks for the feedabck. The Y -axis is a real (perhaps I should round it and convert to double? In RL it will always be 0 to 2,000 and I doubt that anyone would visually notice the decimal parts on a chart). The X-axis is a string (a time label in the format MM:SS, so maybe that is it). I will check it & get back to you. Hmm, maybe it's autoscaling? Wouldn't that have to be calculated at every AddXY() ? – Mawg says reinstate Monica Jan 25 '11 at 03:24
  • Also, in D7, the function is function AddXY(Const AXValue, AYValue: Double; Const AXLabel: String; AColor: TColor) : Longint; and I am passing Chart1.Series[0].Count as the first param.I guess that takes time to calculate too ... or does it? Surely it's just incremented by every call to AddXY ? – Mawg says reinstate Monica Jan 25 '11 at 03:27
  • +1 I give the answer because you have helped me see how to express my question correctly – Mawg says reinstate Monica Jan 25 '11 at 07:41
  • 2
    Real? Isn't that really slow? Why on earth use Real? You should be using Double. – David Heffernan Jan 25 '11 at 07:51
1

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

Michael Küller
  • 3,982
  • 4
  • 22
  • 42
1

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

Brian Frost
  • 13,334
  • 11
  • 80
  • 154