📄 chart.pas
字号:
Function Clicked(x,y:Integer):Boolean;
procedure DrawTitle;
property Caption:String read GetCaption write SetCaption;
property TitleRect:TRect read GetShapeBounds;
published
property AdjustFrame:Boolean read FAdjustFrame write SetAdjustFrame
default True;
property Alignment: TAlignment read FAlignment
write SetAlignment default taCenter;
property Bevel;
property BevelWidth;
property Brush;
property Color;
property CustomPosition; { 5.01 }
property Font;
property Frame;
property Gradient;
property Left; { 5.01 }
property Shadow;
property ShapeStyle;
property Text:TStrings read FText write SetText;
property TextFormat; // 7.02
property Top; { 5.01 }
property Transparency;
property Transparent default True;
property Visible default True;
end;
TChartFootTitle=class(TChartTitle)
public
Constructor Create(AOwner: TCustomTeePanel); override;
end;
TChartClick=procedure( Sender:TCustomChart;
Button:TMouseButton;
Shift: TShiftState;
X, Y: Integer) of object;
TChartClickAxis=procedure( Sender:TCustomChart;
Axis:TChartAxis;
Button:TMouseButton;
Shift: TShiftState;
X, Y: Integer) of object;
TChartClickSeries=procedure( Sender:TCustomChart;
Series:TChartSeries;
ValueIndex:Integer;
Button:TMouseButton;
Shift: TShiftState;
X, Y: Integer) of object;
TChartClickTitle=procedure( Sender:TCustomChart;
ATitle:TChartTitle;
Button:TMouseButton;
Shift: TShiftState;
X, Y: Integer) of object;
TOnGetLegendPos=Procedure( Sender:TCustomChart; Index:Integer;
Var X,Y,XColor:Integer) of object;
TOnGetLegendRect=Procedure( Sender:TCustomChart; Var Rect:TRect) of object;
TAxisSavedScales=Packed Record
Auto : Boolean;
AutoMin : Boolean;
AutoMax : Boolean;
Min : Double;
Max : Double;
end;
TAllAxisSavedScales=Array of TAxisSavedScales;
TChartBackWall=class(TChartWall)
public
Constructor Create(AOwner: TCustomTeePanel); override;
published
property Color default clSilver;
property Transparent default True;
end;
TChartRightWall=class(TChartWall)
published
property Color default clSilver;
property Visible default False;
end;
TChartWalls=class(TPersistent)
private
FBack : TChartBackWall;
FBottom : TChartWall;
FChart : TCustomChart;
FLeft : TChartWall;
FRight : TChartRightWall;
function GetVisible: Boolean;
procedure SetBack(const Value: TChartBackWall);
procedure SetBottom(const Value: TChartWall);
procedure SetLeft(const Value: TChartWall);
procedure SetRight(const Value: TChartRightWall);
procedure SetSize(const Value: Integer);
procedure SetVisible(const Value: Boolean);
public
Constructor Create(Chart:TCustomChart);
Destructor Destroy; override;
Procedure Assign(Source:TPersistent); override;
property Back:TChartBackWall read FBack write SetBack;
property Bottom:TChartWall read FBottom write SetBottom;
property Left:TChartWall read FLeft write SetLeft;
property Right:TChartRightWall read FRight write SetRight;
property Size:Integer write SetSize; // 7.0
property Visible:Boolean read GetVisible write SetVisible;
end;
TChartAllowScrollEvent=Procedure( Sender:TChartAxis; Var AMin,AMax:Double;
Var AllowScroll:Boolean ) of object;
TCustomChart=class(TCustomAxisPanel)
private
FFoot : TChartTitle;
FLegend : TChartLegend;
FSavedScales : TAllAxisSavedScales;
FScrollMouse : TMouseButton;
FSubFoot : TChartTitle;
FSubTitle : TChartTitle;
FTitle : TChartTitle;
FWalls : TChartWalls;
{ events }
FOnAllowScroll : TChartAllowScrollEvent;
FOnClickAxis : TChartClickAxis;
FOnClickBackGround : TChartClick;
FOnClickLegend : TChartClick;
FOnClickSeries : TChartClickSeries;
FOnClickTitle : TChartClickTitle;
FOnGetLegendPos : TOnGetLegendPos;
FOnGetLegendRect : TOnGetLegendRect;
FOnGetLegendText : TOnGetLegendText;
Function ActiveSeriesUseAxis:Boolean;
procedure BroadcastMouseEvent(AEvent:TChartMouseEvent;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Function CalcNeedClickedPart(Pos:TPoint; Needed:Boolean):TChartClickedPart;
Procedure DrawBackWall;
Procedure DrawLeftWall;
Procedure DrawRightWall;
Function DrawWallFirst(APos:Integer):Boolean;
function GetBackWall: TChartBackWall;
function GetBottomWall: TChartWall;
Function GetFrame:TChartPen;
function GetLeftWall: TChartWall;
function GetRightWall: TChartRightWall;
Procedure PrepareWallCanvas(AWall:TChartWall);
procedure ReadBackColor(Reader: TReader);
procedure ReadColorPalette(Reader: TReader);
Procedure RestoreScales(var Saved:TAllAxisSavedScales);
Function SaveScales:TAllAxisSavedScales;
Procedure ScrollVerticalAxes(Up:Boolean);
Procedure SetBackColor(Value:TColor);
Procedure SetBackWall(Value:TChartBackWall);
Procedure SetBottomWall(Value:TChartWall);
Procedure SetFoot(Value:TChartTitle);
Procedure SetFrame(Value:TChartPen);
Procedure SetLeftWall(Value:TChartWall);
Procedure SetLegend(Value:TChartLegend);
Procedure SetRightWall(Value:TChartRightWall);
procedure SetSubFoot(const Value: TChartTitle);
procedure SetSubTitle(const Value: TChartTitle);
procedure SetTitle(Value:TChartTitle);
procedure SetWalls(Value:TChartWalls);
procedure WriteColorPalette(Writer: TWriter);
procedure SetScrollMouseButton(const Value: TMouseButton);
protected
RestoredAxisScales : Boolean;
Procedure CalcWallsRect; override;
Function CalcWallSize(Axis:TChartAxis):Integer; override;
Procedure CalcZoomPoints; dynamic;
Procedure DefineProperties(Filer:TFiler); override;
{$IFDEF CLX}
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
const MousePos: TPoint): Boolean; override;
function DoMouseWheelDown(Shift: TShiftState; const MousePos: TPoint): Boolean; override;
function DoMouseWheelUp(Shift: TShiftState; const MousePos: TPoint): Boolean; override;
{$ELSE}
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
MousePos: TPoint): Boolean; override;
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
{$ENDIF}
Procedure DoZoom(Const TopI,TopF,BotI,BotF,LefI,LefF,RigI,RigF:Double);
{$IFNDEF CLR}
Function DrawLeftWallFirst:Boolean;
Function DrawRightWallAfter:Boolean;
{$ENDIF}
procedure DrawLegendShape(const Rect:TRect); override; // 7.05
procedure DrawTitlesAndLegend(BeforeSeries:Boolean); override;
Procedure DrawWalls; override;
{$IFNDEF CLR}
Function GetBackColor:TColor; override;
Procedure GetChildren(Proc:TGetChildProc; Root:TComponent); override;
{$ENDIF}
Function InternalFormattedLegend( ALegend:TCustomChartLegend;
SeriesOrValueIndex:Integer):String;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
public
ColorPaletteIndex : Integer;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
Procedure Assign(Source:TPersistent); override;
Function AxisTitleOrName(Axis:TChartAxis):String;
Procedure CalcClickedPart(Pos:TPoint; Var Part:TChartClickedPart);
{$IFDEF CLR}
Function DrawLeftWallFirst:Boolean;
Function DrawRightWallAfter:Boolean;
{$ENDIF}
Procedure FillSeriesSourceItems(ASeries:TChartSeries; Proc:TGetStrProc); dynamic;
Procedure FillValueSourceItems(ValueList:TChartValueList; Proc:TGetStrProc); dynamic;
Function GetASeries:TChartSeries; { return first active Series }
{$IFDEF CLR}
Function GetBackColor:TColor; override;
Procedure GetChildren(Proc:TGetChildProc; Root:TComponent); override;
{$ENDIF}
Function IsFreeSeriesColor(AColor:TColor; CheckBackground:Boolean;
ASeries:TChartSeries=nil):Boolean; override;
Procedure NextPage;
Procedure PreviousPage;
Procedure RemoveAllSeries;
Procedure SeriesDown(ASeries:TChartSeries);
Procedure SeriesUp(ASeries:TChartSeries);
procedure UndoZoom; override;
Procedure ZoomPercent(Const PercentZoom:Double);
Procedure ZoomRect(Const Rect:TRect);
Function FormattedValueLegend(ASeries:TChartSeries; ValueIndex:Integer):String; override;
Function FormattedLegend(SeriesOrValueIndex:Integer):String;
property BackColor:TColor read GetBackColor write SetBackColor; { compatibility }
property Walls:TChartWalls read FWalls write SetWalls;
{ to be published }
property BackWall:TChartBackWall read GetBackWall write SetBackWall;
property Frame:TChartPen read GetFrame write SetFrame;
property BottomWall:TChartWall read GetBottomWall write SetBottomWall;
property Foot:TChartTitle read FFoot write SetFoot;
property LeftWall:TChartWall read GetLeftWall write SetLeftWall;
property Legend:TChartLegend read FLegend write SetLegend;
property RightWall:TChartRightWall read GetRightWall write SetRightWall;
property ScrollMouseButton:TMouseButton read FScrollMouse write SetScrollMouseButton default mbRight;
property SubFoot:TChartTitle read FSubFoot write SetSubFoot;
property SubTitle:TChartTitle read FSubTitle write SetSubTitle;
property Title:TChartTitle read FTitle write SetTitle;
{ events }
property OnAllowScroll:TChartAllowScrollEvent read FOnAllowScroll write FOnAllowScroll;
property OnClickAxis:TChartClickAxis read FOnClickAxis write FOnClickAxis;
property OnClickBackground:TChartClick read FOnClickbackground write FOnClickBackGround;
property OnClickLegend:TChartClick read FOnClickLegend write FOnClickLegend;
property OnClickSeries:TChartClickSeries read FOnClickSeries write FOnClickSeries;
property OnClickTitle:TChartClickTitle read FOnClickTitle write FOnClickTitle;
property OnGetLegendPos:TOnGetLegendPos read FOnGetLegendPos write FOnGetLegendPos;
property OnGetLegendRect:TOnGetLegendRect read FOnGetLegendRect write FOnGetLegendRect;
property OnGetLegendText:TOnGetLegendText read FOnGetLegendText write FOnGetLegendText;
{ TPanel properties }
property Align;
property BevelInner;
property BevelOuter;
property BevelWidth;
{$IFDEF CLX}
property Bitmap;
{$ENDIF}
property BorderWidth;
property Color;
{$IFNDEF CLX}
property UseDockManager default True;
property DockSite;
property DragCursor;
{$ENDIF}
property DragMode;
property Enabled;
property ParentColor;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property Anchors;
{$IFNDEF CLX}
property AutoSize;
{$ENDIF}
property Constraints;
{$IFNDEF CLX}
property DragKind;
{$IFNDEF LCL}
property Locked;
{$ENDIF}
{$ENDIF}
{ TPanel events }
property OnClick;
{$IFDEF D5}
property OnContextPopup;
{$ENDIF}
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnStartDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
{$IFNDEF CLX}
{$IFNDEF LCL}
property OnCanResize;
{$ENDIF}
{$ENDIF}
property OnConstrainedResize;
{$IFNDEF CLX}
property OnDockDrop;
property OnDockOver;
property OnEndDock;
property OnGetSiteInfo;
property OnStartDock;
property OnUnDock;
{$ENDIF}
{$IFDEF K3}
property OnMouseEnter;
property OnMouseLeave;
{$ELSE}
{$IFDEF D10}
property OnMouseEnter;
property OnMouseLeave;
{$ENDIF}
{$ENDIF}
end;
TChart=class(TCustomChart)
{$IFNDEF CLX}
public
property DockManager;
{$ENDIF}
published
{ TCustomChart Properties }
property AllowPanning;
property BackImage;
property BackImageInside;
property BackImageMode;
property BackImageTransp;
property BackWall;
property Border;
property BorderRound;
property BottomWall;
property Foot;
property Gradient;
property LeftWall;
property Legend;
property MarginBottom;
property MarginLeft;
property MarginRight;
property MarginTop;
property MarginUnits;
property PrintProportional;
property RightWall;
property ScrollMouseButton;
property SubFoot;
property SubTitle;
property Title;
{ TCustomChart Events }
property OnAllowScroll;
property OnClickAxis;
property OnClickBackground;
property OnClickLegend;
property OnClickSeries;
property OnClickTitle;
property OnGetLegendPos;
property OnGetLegendRect;
property OnScroll;
property OnUndoZoom;
property OnZoom;
{ TCustomAxisPanel properties }
property AxisBehind;
property AxisVisible;
property BottomAxis;
property Chart3DPercent;
property ClipPoints;
property DepthAxis;
property DepthTopAxis;
property CustomAxes;
property Frame;
property LeftAxis;
property MaxPointsPerPage;
property Monochrome;
property Page;
property RightAxis;
property ScaleLastPage;
property SeriesList;
property Shadow;
property TopAxis;
property View3D;
property View3DOptions;
property View3DWalls;
property Zoom;
{ TCustomAxisPanel events }
property OnAfterDraw;
property OnBeforeDrawAxes;
property OnBeforeDrawChart;
property OnBeforeDrawSeries;
property OnBeforePrint;
property OnGetAxisLabel;
property OnGetLegendText;
property OnGetNextAxisLabel;
property OnPageChange;
{ TPanel properties }
property Align;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BorderWidth;
property Color;
{$IFNDEF CLX}
property UseDockManager default True;
property DockSite;
property DragCursor;
property DragMode;
{$ELSE}
property DragMode;
{$ENDIF}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -