大TChart需要很长时间才能绘制 [英] Large TChart takes a long time to draw

查看:128
本文介绍了大TChart需要很长时间才能绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

热门文章:我已经接受了答案,但对我来说不起作用。我将发布一个新问题,并强调Delphi7。感谢所有付出的人一些好的输入

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 measurements taken at one second intervals over an hour.

我之前有一个问题,即更新TStringGrid花费了45秒,并设法将其降低到比眼睛能看到的更快。部分原因是通过移动循环的一些与计算和数据库相关的功能,但是-令我惊讶的是,真正与众不同的更改是在循环之前将strindgrid的rowCount设置为3600,而不是在循环内对其进行递增。

I had a previous question where it was taking 45 seconds to updates a TStringGrid and managed to get that down to "faster than the eye can see". Partly by moving some computation and database related functionality of of the loop, but - surprisingly to me - the change that really made the difference was setting the strindgrid's rowCount to 3600 before the loop rather than incrementing it inside the loop.

现在我在TChart上遇到了类似的问题。也许我尝试预先分配图表?因此,我可以 Chart1.Series [0] .Count:= 3600 ,但是我不能使用 AddXy() Add(),那么如何显式设置串联值?

Now I have a similar problem with a TChart. Maybe if I try preallocating the chart? So, I could Chart1.Series[0].Count := 3600, but than I can't use AddXy() or Add(), so how would I explicitly set the values in series?

我有一个非常简单的图表,y轴为浮点数,x轴为hour:seconds

I have a very simple chart, with Floats on the y-axis and hour:seconds on the x-axis

任何人都可以帮忙,或提出另一种加快图表绘制速度的建议吗?

Can anyone help, or suggest another way to speed up chart drawing?

更新:有些人建议使用 TFastLineSeries ,但我看不到。

Update: several have suggested using TFastLineSeries, but I don't see how.

啊哈-双击图表,显示所有系列,选择一个&单击更改

Aha - double click on the Chart, to show all series, select one & click change

推荐答案

我眨眨眼就能绘制出数百万的数据点。我的操作方法如下:
您可以做的是为X和Y值创建两个数组,并用值填充它们,然后将这些数组添加到图表中。例如:

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;

使用TFastLineSeries而不是常规的TLineSeries来加快绘图速度。使用FastlineSeries时,还具有DrawAllPoints属性。设置为false时,绘图会更快。然后,TChart将跳过与屏幕上其他数据点共享相同X位置的数据点。它只会得出这些的第一点。

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.

在这里可以找到DrawAllPoints选项:

This is where you find it the DrawAllPoints option:

这篇关于大TChart需要很长时间才能绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆