1

我想获得一些关于使用 TeeChart TAreaSeries 的提示,特别是关于创建不重叠系列的提示。

当我在同一个图上创建两个区域系列时,与相同的 BottomAxis 和 LeftAxis 相关,我得到如下信息:

https://skydrive.live.com/redir?resid=9966BBBE2447AA89!116&authkey=!AKm6DMvrxleX5ps

如果我垂直滚动绘图,我会看到这两个系列无休止地向下扩展至负无穷大(Y 坐标)。

但我想知道是否可以在某个 Y 点“剪切”该系列的下部?这样我就可以检索到这样的东西:

https://skydrive.live.com/redir?resid=9966BBBE2447AA89!115&authkey=!AGaejDREPKnPYMY

(对不起,链接而不是图片,由于声誉限制,我无权发布它们)

4

1 回答 1

1

是的,您可以在 TeeChart 的程序组提供的新功能演示中的All Features\Welcome!\Axes\Opaque zone示例中执行某些操作,例如:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeeGDIPlus, TeEngine, Series, ExtCtrls, TeeProcs, Chart;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TAreaSeries;
    Series2: TAreaSeries;
    procedure FormCreate(Sender: TObject);
    procedure Series1Click(Sender: TChartSeries; ValueIndex: Integer;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure Chart1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    ClipRect: TRect;
    procedure SeriesBeforeDraw(Sender: TObject);
    procedure SeriesAfterDraw(Sender: TObject);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses TeCanvas;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.BeforeDrawValues:=SeriesBeforeDraw;
  Series1.AfterDrawValues:=SeriesAfterDraw;
end;

procedure TForm1.SeriesBeforeDraw(Sender: TObject);

  Function SeriesRect(Series:TChartSeries):TRect;
  begin
    With result do
    begin
      Left:=Series.GetHorizAxis.IStartPos;
      Right:=Series.GetHorizAxis.IEndPos;
      Top:=Series.GetVertAxis.IStartPos;
      Bottom:=Series.GetVertAxis.CalcYPosValue(700);
    end;
  end;

begin
  ClipRect:=SeriesRect( Sender as TChartSeries );

  { make opaque }
  With Chart1 do
       if CanClip then
          Canvas.ClipRectangle(ClipRect);
end;

procedure TForm1.SeriesAfterDraw(Sender: TObject);
begin
  Chart1.Canvas.UnClipRectangle;
end;

procedure TForm1.Series1Click(Sender: TChartSeries; ValueIndex: Integer;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Caption:=IntToStr(ValueIndex);
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Series1.Clicked(X,Y)<>-1) then
    Chart1.CancelMouse:=not PointInRect(ClipRect,X,Y);
end;

end.

生成此图表:

在此处输入图像描述

于 2013-07-19T14:44:27.143 回答