【问题标题】:Delphi XE2 Graph slowDelphi XE2 图形慢
【发布时间】:2015-11-18 00:48:03
【问题描述】:

我正在制作一个 Delphi 应用程序,我想用它在图表中显示数据。这些数据来自串行端口,所以我想“实时”看到发生了什么。我注意到一段时间后我的应用程序变得非常缓慢。我认为这与更新图表有关。有人可以帮助我加快申请速度吗?出于测试目的,我制作了这个测试应用程序,我每 5 毫秒获取一个随机数并将其添加到图表中,所以这不是我的最终应用程序,但效果是相同的。如果我尝试使用 GetTickCount 测量时间,我会看到“中间”时间增加。在我的最终应用程序中,我需要能够放置 12 个图表。有没有办法让它更快?

谢谢!

Source

单元主单元;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, VCLTee.TeEngine,
  VCLTee.Series, VCLTee.TeeProcs, VCLTee.Chart, DateUtils, Vcl.StdCtrls,
  Vcl.ComCtrls, Math;

type
  TMainForm = class(TForm)
    Chart01: TChart;
    AreaSeries4: TAreaSeries;
    Panel1: TPanel;
    Timer1: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    AddLabel: TLabel;
    InBetweenLabel: TLabel;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    AfterAddPoint: integer;
    procedure FillChart(RealValue: real);
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation


procedure TMainForm.FillChart(RealValue: real);
var Chart: TChart;
begin
  Chart:=MainForm.Chart01;

  Chart.Axes.Bottom.SetMinMax(IncMinute(Now, -20), Now);  //Moet hier staan, anders worden grafieken niet live geupdate

  Chart.Series[0].AddXY(Now, RealValue, '' );

end;
{$R *.dfm}

procedure TMainForm.Timer1Timer(Sender: TObject);
var BeforeAddPoint, Diverence: integer;
begin
  BeforeAddPoint:= GetTickCount;
  Diverence:=BeforeAddPoint-AfterAddPoint;
  InBetweenLabel.Caption:=IntToStr(Diverence);

  FillChart(RandomRange(50,52));

  AfterAddPoint:=GetTickCount;
  Diverence:=AfterAddPoint-BeforeAddPoint;
  AddLabel.Caption:=IntToStr(Diverence);

end;

end.

【问题讨论】:

  • 我们不是很了解。我们不知道您使用的是什么类型的系列。当然,TChart 可以有效地显示大量数据。
  • 是的,我使用 TChart。和AreaSeries。我想制作一个将旧数据滚动到左侧并在右侧添加新数据的图表。这有帮助吗?我添加了一个项目链接。
  • 您使用区域系列的信息非常重要。如果我是你,我会制作一个 MCVE,以便我们进行调查。
  • 我想这就是我所做的。我做了一个简单的例子,我可以用它来重现这个问题。你可以下载它。请参阅链接“来源”。或者这不是你的意思吗?
  • 它必须在问题中。站外链接不好。

标签: delphi delphi-xe2 teechart


【解决方案1】:

关于在您的应用程序中使用和优化 TeeChart,我强烈建议您遵循 实时图表 文章 http://www.teechart.net/reference/articles/index.php

中的说明

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-24
    • 2011-12-19
    • 2023-03-27
    • 2012-09-22
    • 2011-11-26
    相关资源
    最近更新 更多