⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 series.pas

📁 第三方控件:PaintGrid.pas 网格型仪表控件源文件 Mymeter.pas 圆型仪表控件源文件 Project1是这两个控件的使用范例。 该
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{*********************************************}
{  TeeChart Standard Series Types             }
{  Copyright (c) 1995-2005 by David Berneda   }
{  All Rights Reserved                        }
{                                             }
{   TCustomSeries                             }
{     TLineSeries                             }
{      THorizLineSeries                       }
{     TAreaSeries                             }
{      THorizAreaSeries                       }
{     TPointSeries                            }
{   TCustomBarSeries                          }
{     TBarSeries                              }
{     THorizBarSeries                         }
{   TCircledSeries                            }
{     TPieSeries                              }
{   TFastLineSeries                           }
{                                             }
{*********************************************}
unit Series;
{$I TeeDefs.inc}

interface

{$IFDEF D9}
{$INLINE OFF}  // Enable or disable inlining in Delphi 9
{$ENDIF}

uses
  {$IFNDEF LINUX}
  Windows,
  {$ENDIF}
  {$IFDEF CLX}
  QGraphics, QForms, QTypes,
  {$ELSE}
  Graphics, Forms,
  {$ENDIF}
  {$IFDEF D9}
  Types,
  {$ENDIF}
  SysUtils, Classes, TeEngine, Chart, TeCanvas, TeeProcs;

const
  PiDegree : Double = Pi/180.0;
  Tee_PieShadowColor = TColor($A0A0A0);

type
  TCustomLineSeries=class(TChartSeries)
  protected
    Function GetLinePen:TChartPen;
  public
    property LinePen:TChartPen read GetLinePen write SetPen;
  end;

  TCustomSeries=class;

  TSeriesClickPointerEvent=Procedure( Sender:TCustomSeries;
                                      ValueIndex:Integer;
                                      X, Y: Integer) of object;

  TCustomSeriesStack=(cssNone, cssOverlap, cssStack, cssStack100);

  TOnGetPointerStyle=Function( Sender:TChartSeries;
                               ValueIndex:Integer):TSeriesPointerStyle of object;

  TCustomSeries=class(TCustomLineSeries)
  private
    FAreaBrush          : TChartBrush;
    FAreaColor          : TColor;
    FAreaLinesPen       : TChartPen;
    FClickableLine      : Boolean;
    FColorEachLine      : Boolean;
    FDark3D             : Boolean;
    FDrawArea           : Boolean;
    FDrawLine           : Boolean;
    FInvertedStairs     : Boolean;
    FLineHeight         : Integer;
    FOutLine            : TChartHiddenPen;
    FPointer            : TSeriesPointer;
    FShadow             : TTeeShadow;  // 7.0
    FStacked            : TCustomSeriesStack;
    FStairs             : Boolean;
    FTransparency       : TTeeTransparency;

    { events }
    FOnClickPointer     : TSeriesClickPointerEvent;
    FOnGetPointerStyle  : TOnGetPointerStyle;

    { internal }
    BottomPos      : Integer;
    OldBottomPos   : Integer;
    OldX           : Integer;
    OldY           : Integer;
    OldColor       : TColor;
    tmpDark3DRatio : Double;

    Function CalcStackedPos(ValueIndex:Integer; Value:Double):Integer;
    Function GetAreaBrush:TBrushStyle;
    Function GetLineBrush:TBrushStyle;
    Procedure InternalCalcMargin(SameSide,Horizontal:Boolean; var A,B:Integer);
    Function PointOrigin(ValueIndex:Integer; SumAll:Boolean):Double;

    Procedure SetAreaBrush(Value:TChartBrush);
    Procedure SetAreaBrushStyle(Value:TBrushStyle);
    Procedure SetAreaColor(Value:TColor);
    Procedure SetAreaLinesPen(Value:TChartPen);
    procedure SetColorEachLine(const Value: Boolean);
    Procedure SetDark3D(Value:Boolean);
    Procedure SetDrawArea(Value:Boolean);
    Procedure SetGradient(Value:TChartGradient);
    Procedure SetInvertedStairs(Value:Boolean);
    Procedure SetLineBrush(Value:TBrushStyle);
    Procedure SetLineHeight(Value:Integer);
    procedure SetOutLine(const Value: TChartHiddenPen);
    Procedure SetPointer(Value:TSeriesPointer);
    Procedure SetShadow(Value:TTeeShadow);
    Procedure SetStacked(Value:TCustomSeriesStack);
    Procedure SetStairs(Value:Boolean);
  protected
    FGradient : TChartGradient;

    Procedure CalcHorizMargins(Var LeftMargin,RightMargin:Integer); override;
    Function CalcMarkLength:Integer; virtual;
    Procedure CalcVerticalMargins(Var TopMargin,BottomMargin:Integer); override;
    Procedure CalcZOrder; override;

    Function ClickedPointer( ValueIndex,tmpX,tmpY:Integer;
                             x,y:Integer):Boolean; virtual;

    function DoGetPointerStyle(ValueIndex:Integer):TSeriesPointerStyle;

    Procedure DrawAllValues; override; { 5.02 }
    Procedure DrawLegendShape(ValueIndex:Integer; Const Rect:TRect); override;
    Procedure DrawMark( ValueIndex:Integer; Const St:String;
                        APosition:TSeriesMarkPosition); override;
    Procedure DrawPointer(AX,AY:Integer; AColor:TColor; ValueIndex:Integer); dynamic;
    procedure DrawValue(ValueIndex:Integer); override;

    Function GetAreaBrushColor(AColor:TColor):TColor;
    class Function GetEditorClass:String; override;
    Function GetGradient:TChartGradient; virtual;
    Function GetTransparency:TTeeTransparency; virtual;
    procedure SetTransparency(const Value: TTeeTransparency); virtual;

    property Gradient:TChartGradient read GetGradient write SetGradient; { 5.03 }

    procedure LinePrepareCanvas(tmpCanvas:TCanvas3D; tmpColor:TColor);
    procedure PreparePointer(ValueIndex:Integer); virtual;
    Procedure SetParentChart(Const Value:TCustomAxisPanel); override;

    property Stacked:TCustomSeriesStack read FStacked write SetStacked default cssNone;
    property Transparency:TTeeTransparency read GetTransparency write SetTransparency default 0;
  public
    Constructor Create(AOwner: TComponent); override;
    Destructor Destroy; override;

    Procedure Assign(Source:TPersistent); override;
    Function CalcXPos(ValueIndex:Integer):Integer; override;
    Function CalcYPos(ValueIndex:Integer):Integer; override;
    Function Clicked(x,y:Integer):Integer; override;
    Function GetOriginPos(ValueIndex:Integer):Integer; virtual;
    Function MaxXValue:Double; override;
    Function MinXValue:Double; override;
    Function MaxYValue:Double; override;
    Function MinYValue:Double; override;

    property AreaBrush:TBrushStyle read GetAreaBrush write SetAreaBrushStyle
                                        default bsSolid;
    property AreaChartBrush:TChartBrush read FAreaBrush write SetAreaBrush;
    property AreaColor:TColor read FAreaColor write SetAreaColor default clTeeColor;
    property AreaLinesPen:TChartPen read FAreaLinesPen write SetAreaLinesPen;
    property ClickableLine:Boolean read FClickableLine write FClickableLine default True;
    property ColorEachLine:Boolean read FColorEachLine write SetColorEachLine default True;
    property Dark3D:Boolean read FDark3D write SetDark3D default True;
    property DrawArea:Boolean read FDrawArea write SetDrawArea default False;
    property InvertedStairs:Boolean read FInvertedStairs write SetInvertedStairs default False;
    property LineBrush:TBrushStyle read GetLineBrush write SetLineBrush default bsSolid;
    property LineHeight:Integer read FLineHeight write SetLineHeight default 0;
    property OutLine:TChartHiddenPen read FOutLine write SetOutLine;
    property Pointer:TSeriesPointer read FPointer write SetPointer;
    property Shadow:TTeeShadow read FShadow write SetShadow;  // 7.0
    property Stairs:Boolean read FStairs write SetStairs default False;

    { events }
    property OnClickPointer:TSeriesClickPointerEvent read FOnClickPointer
                                                     write FOnClickPointer;
  published
    { events }
    property OnGetPointerStyle:TOnGetPointerStyle read FOnGetPointerStyle
                                                  write FOnGetPointerStyle;
  end;

  TLineSeries=Class(TCustomSeries)
  protected
    class Procedure CreateSubGallery(AddSubChart:TChartSubGalleryProc); override;
    Procedure PrepareLegendCanvas( ValueIndex:Integer; Var BackColor:TColor;
                                   Var BrushStyle:TBrushStyle); override;
    class Procedure SetSubGallery(ASeries:TChartSeries; Index:Integer); override;
  public
    Constructor Create(AOwner: TComponent); override;
    Procedure Assign(Source:TPersistent); override;
  published
    property Active;
    property ColorEachLine;
    property ColorEachPoint;
    property ColorSource;
    property Cursor;
    property Depth;
    property HorizAxis;
    property Marks;
    property ParentChart;
    property DataSource;  { after parentchart }
    property PercentFormat;
    property SeriesColor;
    property Shadow; // 7.02
    property ShowInLegend;
    property Stacked;
    property Title;
    property ValueFormat;
    property VertAxis;
    property XLabelsSource;

    { events }
    property AfterDrawValues;
    property BeforeDrawValues;
    property OnAfterAdd;
    property OnBeforeAdd;
    property OnClearValues;
    property OnClick;
    property OnDblClick;
    property OnGetMarkText;
    property OnMouseEnter;
    property OnMouseLeave;

    property Brush;
    property ClickableLine;
    property Dark3D;
    property InvertedStairs;
    property LineBrush;
    property LineHeight;
    property LinePen;
    property OutLine; { 5.02 }
    property Pointer;
    property Stairs;
    property XValues;
    property YValues;
  end;

  THorizLineSeries=class(TLineSeries)
  protected
    Function CalcMarkLength:Integer; override;
    Procedure DrawMark( ValueIndex:Integer; Const St:String;
                        APosition:TSeriesMarkPosition); override;
  public
    Constructor Create(AOwner: TComponent); override;
  end;

  TPointSeries=Class(TCustomSeries)
  private
    Procedure SetFixed;
  protected
    class Function CanDoExtra:Boolean; virtual;
    class Procedure CreateSubGallery(AddSubChart:TChartSubGalleryProc); override;
    class Function GetEditorClass:String; override;
    Function GetTransparency:TTeeTransparency; override;
    Procedure PrepareForGallery(IsEnabled:Boolean); override;
    Procedure SetColorEachPoint(Value:Boolean); override;
    class Procedure SetSubGallery(ASeries:TChartSeries; Index:Integer); override;
    procedure SetTransparency(const Value: TTeeTransparency); override;  // 7.0
  public
    Constructor Create(AOwner: TComponent); override;
    Procedure Assign(Source:TPersistent); override;
  published
    property Active;
    property ColorEachPoint;
    property ColorSource;
    property Cursor;
    property Depth;
    property HorizAxis;
    property Marks;
    property ParentChart;
    property DataSource;  { after parentchart }
    property PercentFormat;
    property SeriesColor;
    property ShowInLegend;
    property Stacked;
    property Title;
    property ValueFormat;
    property VertAxis;
    property XLabelsSource;

    { events }
    property AfterDrawValues;
    property BeforeDrawValues;
    property OnAfterAdd;
    property OnBeforeAdd;
    property OnClearValues;
    property OnClick;
    property OnDblClick;
    property OnGetMarkText;
    property OnMouseEnter;
    property OnMouseLeave;

    // Published inherited properties
    property ClickableLine;
    property Pointer;
    property Transparency;
    property XValues;
    property YValues;

    { events }
    property OnClickPointer;
  end;

  TMultiArea=(maNone,maStacked,maStacked100);

  TAreaSeries=Class(TCustomSeries)
  private
    FUseOrigin : Boolean;
    FOrigin    : Double;
    Function GetMultiArea:TMultiArea;
    Procedure SetMultiArea(Value:TMultiArea);
    Procedure SetOrigin(Const Value:Double);
    Procedure SetUseOrigin(Value:Boolean);
  protected
    class Procedure CreateSubGallery(AddSubChart:TChartSubGalleryProc); override;
    Procedure DrawLegendShape(ValueIndex:Integer; Const Rect:TRect); override; // 5.03
    class Function GetEditorClass:String; override;
    Procedure PrepareForGallery(IsEnabled:Boolean); override;
    Procedure PrepareLegendCanvas( ValueIndex:Integer; Var BackColor:TColor;
                                   Var BrushStyle:TBrushStyle); override;
    class Procedure SetSubGallery(ASeries:TChartSeries; Index:Integer); override;
  public
    Constructor Create(AOwner: TComponent); override;
    Procedure Assign(Source:TPersistent); override;
    Function DrawSeriesForward(ValueIndex:Integer):Boolean; override;
    Function GetOriginPos(ValueIndex:Integer):Integer; override;
    Function MaxXValue:Double; override;
    Function MinXValue:Double; override;
    Function MaxYValue:Double; override;
    Function MinYValue:Double; override;
  published
    property Active;
    property ColorEachLine;
    property ColorEachPoint;
    property ColorSource;
    property Cursor;
    property Depth;
    property Gradient; { 5.03 }
    property HorizAxis;
    property Marks;
    property ParentChart;
    property DataSource;  { after parentchart }
    property PercentFormat;
    property SeriesColor;
    property ShowInLegend;
    property Title;
    property ValueFormat;
    property VertAxis;
    property XLabelsSource;

    { events }
    property AfterDrawValues;
    property BeforeDrawValues;
    property OnAfterAdd;
    property OnBeforeAdd;
    property OnClearValues;
    property OnClick;
    property OnDblClick;
    property OnGetMarkText;
    property OnMouseEnter;
    property OnMouseLeave;

    property AreaBrush;
    property AreaChartBrush;
    property AreaColor;
    property AreaLinesPen;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -