Large TChart takes a long time to draw

前端 未结 3 1259
难免孤独
难免孤独 2021-01-21 06:58

Top post: I have accepted an answer,but it doesn\'t work for me. I will post a new question, stressing Delphi 7. Thanks to all who gave some good input


I have me

相关标签:
3条回答
  • 2021-01-21 07:18

    I would just like to comment on the Michael Schmooks answer. Using High(XValues) to set the Count value for the series causes the last item in the array not to be displayed. This is because high(XValues) returns the highest index of the array, and not the size of the array.

    Of course, this is only noticed when a very low nr of items happens to be added.

    Chart.Series[0].XValues.Count := high(XValues) + 1;
    
    0 讨论(0)
  • 2021-01-21 07:19

    I manage to draw millons of datapoints in a blink of an eye. Here's how I do it: What you can do is to create two arrays for the X and Y Values, fill them with your values and then these arrays to your chart. For example:

    var
      XValues, YValues: array of double; 
    begin
    
      SetLength(XValues, numberofValues);
      SetLength(YValues, numberofValues);
    
      for ix := 0 to numberofValues - 1 do 
      begin
        XValues[ix] := ...your values
        YValues[ix] := ...your values
      end;
    
      Chart.Series[0].XValues.Value := TChartValues(XValues);
      Chart.Series[0].XValues.Count := high(XValues);
      Chart.Series[0].XValues.Modified := true;
      Chart.Series[0].YValues.Value := TChartValues(YValues);
      Chart.Series[0].YValues.Count := high(YValues);
      Chart.Series[0].YValues.Modified := True;
    

    What also speeds up the drawing is using the TFastLineSeries instead of the regular TLineSeries. When using the FastlineSeries you also have the property DrawAllPoints. When set to false the drawing is even faster. TChart will then skip datapoints that share the same X Position with other datapoints on the screen. It will only draw the first point of these.

    This is where you find it the DrawAllPoints option: alt text

    0 讨论(0)
  • 2021-01-21 07:38

    You can find the "official" recommendations about fast charting on Steema website

    0 讨论(0)
提交回复
热议问题