series.pas
来自「Delphi TeeChartPro.6.01的源代码」· PAS 代码 · 共 1,933 行 · 第 1/5 页
PAS
1,933 行
end;
TCustomBarSeries=class(TChartSeries)
private
FAutoBarSize : Boolean;
FAutoMarkPosition: Boolean;
FBarStyle : TBarStyle;
FBarWidthPercent : Integer;
FBevelSize : Integer;
FConePercent : Integer;
FDark3D : Boolean;
FGradient : TBarSeriesGradient;
FMultiBar : TMultiBar;
FOffsetPercent : Integer;
FSideMargins : Boolean;
FStackGroup : Integer;
FTransparency : TTeeTransparency;
FUseOrigin : Boolean;
FOrigin : Double;
{ events }
FOnGetBarStyle : TGetBarStyleEvent;
{ internal }
FBarBounds : TRect;
INumBars : Integer;
IMaxBarPoints : Integer;
IOrderPos : Integer;
IPreviousCount : Integer;
Procedure CalcGradientColor(ValueIndex:Integer);
Function CreateBlend:TTeeBlend;
Procedure DrawBevel;
Function GetBarBrush:TChartBrush;
Function GetBarPen:TChartPen;
Function GetBarStyle(ValueIndex:Integer):TBarStyle;
Procedure SetAutoBarSize(Value:Boolean);
Procedure SetAutoMarkPosition(Value:Boolean);
Procedure SetBarWidthPercent(Value:Integer);
Procedure SetOffsetPercent(Value:Integer);
Procedure SetBarStyle(Value:TBarStyle);
procedure SetBevelSize(const Value: Integer);
procedure SetConePercent(const Value: Integer);
Procedure SetDark3d(Value:Boolean);
Procedure SetGradient(Value:TBarSeriesGradient);
Procedure SetMultiBar(Value:TMultiBar);
Procedure SetOrigin(Const Value:Double);
Procedure SetOtherBars(SetOthers:Boolean);
Procedure SetSideMargins(Value:Boolean);
Procedure SetStackGroup(Value:Integer);
procedure SetTransparency(const Value: TTeeTransparency);
Procedure SetUseOrigin(Value:Boolean);
Procedure BarGradient(ValueIndex:Integer; R:TRect);
Procedure InternalApplyBarMargin(Var MarginA,MarginB:Integer);
Function InternalGetOriginPos(ValueIndex:Integer; DefaultOrigin:Integer):Integer;
Function MaxMandatoryValue(Const Value:Double):Double;
Function MinMandatoryValue(Const Value:Double):Double;
protected
IBarSize : Integer; { 5.01 }
FCustomBarSize : Integer;
Procedure CalcZOrder; override;
class procedure CreateSubGallery(AddSubChart:TChartSubGalleryProc); override;
Procedure DoBeforeDrawChart; override;
Procedure DrawLegendShape(ValueIndex:Integer; Const Rect:TRect); override;
class Function GetEditorClass:String; override;
Function InternalCalcMarkLength(ValueIndex:Integer):Integer; virtual; abstract;
Function InternalClicked(ValueIndex:Integer; P:TPoint):Boolean; virtual; abstract;
Procedure PrepareForGallery(IsEnabled:Boolean); override;
Procedure PrepareLegendCanvas( ValueIndex:Integer; Var BackColor:TColor;
Var BrushStyle:TBrushStyle); override;
Procedure SetCustomBarSize(Value:Integer); { 5.01 BCB cannot if private }
Procedure SetParentChart(Const Value:TCustomAxisPanel); override;
class Procedure SetSubGallery(ASeries:TChartSeries; Index:Integer); override;
class Function SubGalleryStack:Boolean; virtual;
property Transparency:TTeeTransparency read FTransparency write SetTransparency default 0;
public
NormalBarColor : TColor;
Constructor Create(AOwner:TComponent); override;
Destructor Destroy; override;
Function AddBar(Const AValue:Double; Const ALabel:String; AColor:TColor):Integer;
Function ApplyBarOffset(Position:Integer):Integer;
Procedure Assign(Source:TPersistent); override;
Function BarMargin:Integer; {virtual; 4.02 }
Procedure BarRectangle(BarColor:TColor; ALeft,ATop,ARight,ABottom:Integer);
Function CalcMarkLength(ValueIndex:Integer):Integer;
Function Clicked(x,y:Integer):Integer; override;
Function NumSampleValues:Integer; override;
Function PointOrigin(ValueIndex:Integer; SumAll:Boolean):Double; virtual;
Procedure SetPenBrushBar(BarColor:TColor);
property BarBounds:TRect read FBarBounds;
property ConePercent:Integer read FConePercent write SetConePercent
default 0;
published
property Active;
property BarBrush:TChartBrush read GetBarBrush write SetBrush;
property BarPen:TChartPen read GetBarPen write SetPen;
property BevelSize:Integer read FBevelSize write SetBevelSize default 1;
property ColorEachPoint;
property ColorSource;
property Cursor;
property Depth;
property HorizAxis;
property Marks;
property ParentChart;
property DataSource;
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 AutoBarSize:Boolean read FAutoBarSize write SetAutoBarSize default False;
property AutoMarkPosition:Boolean read FAutoMarkPosition write SetAutoMarkPosition default True;
property BarStyle:TBarStyle read FBarStyle write SetBarStyle
default bsRectangle;
property BarWidthPercent:Integer read FBarWidthPercent
write SetBarWidthPercent default 70;
property Dark3D:Boolean read FDark3D write SetDark3D default True;
property Gradient:TBarSeriesGradient read FGradient write SetGradient;
property MultiBar:TMultiBar read FMultiBar write SetMultiBar default mbSide;
property OffsetPercent:Integer read FOffsetPercent
write SetOffsetPercent default 0;
property SideMargins:Boolean read FSideMargins write SetSideMargins default True;
property StackGroup:Integer read FStackGroup write SetStackGroup default 0;
property UseYOrigin:Boolean read FUseOrigin write SetUseOrigin default True;
property YOrigin:Double read FOrigin write SetOrigin;
{ inherited published }
property XValues;
property YValues;
{ events }
property OnGetBarStyle:TGetBarStyleEvent read FOnGetBarStyle write
FOnGetBarStyle;
end;
TBarSeries=class(TCustomBarSeries)
protected
Procedure CalcHorizMargins(Var LeftMargin,RightMargin:Integer); override;
Procedure CalcVerticalMargins(Var TopMargin,BottomMargin:Integer); override;
procedure DrawValue(ValueIndex:Integer); override;
Procedure DrawMark( ValueIndex:Integer; Const St:String;
APosition:TSeriesMarkPosition); override;
Function InternalCalcMarkLength(ValueIndex:Integer):Integer; override;
Function InternalClicked(ValueIndex:Integer; P:TPoint):Boolean; override;
Function MoreSameZOrder:Boolean; override;
public
Constructor Create(AOwner:TComponent); override;
Function CalcXPos(ValueIndex:Integer):Integer; override;
Function CalcYPos(ValueIndex:Integer):Integer; override;
Procedure DrawBar(BarIndex,StartPos,EndPos:Integer); virtual;
Function DrawSeriesForward(ValueIndex:Integer):Boolean; override;
Function GetOriginPos(ValueIndex:Integer):Integer;
Function MaxXValue:Double; override;
Function MinXValue:Double; override;
Function MaxYValue:Double; override;
Function MinYValue:Double; override;
property BarWidth:Integer read IBarSize;
published
property CustomBarWidth:Integer read FCustomBarSize
write SetCustomBarSize default 0;
end;
THorizBarSeries=class(TCustomBarSeries)
protected
Procedure CalcHorizMargins(Var LeftMargin,RightMargin:Integer); override;
Procedure CalcVerticalMargins(Var TopMargin,BottomMargin:Integer); override;
procedure DrawValue(ValueIndex:Integer); override;
Procedure DrawMark( ValueIndex:Integer; Const St:String;
APosition:TSeriesMarkPosition); override;
Function InternalCalcMarkLength(ValueIndex:Integer):Integer; override;
Function InternalClicked(ValueIndex:Integer; P:TPoint):Boolean; override;
public
Constructor Create(AOwner:TComponent); override;
Function CalcXPos(ValueIndex:Integer):Integer; override;
Function CalcYPos(ValueIndex:Integer):Integer; override;
Procedure DrawBar(BarIndex,StartPos,EndPos:Integer); virtual;
Function DrawSeriesForward(ValueIndex:Integer):Boolean; override;
Function GetOriginPos(ValueIndex:Integer):Integer;
Function MaxXValue:Double; override;
Function MinXValue:Double; override;
Function MaxYValue:Double; override;
Function MinYValue:Double; override;
property BarHeight:Integer read IBarSize;
published
property CustomBarHeight:Integer read FCustomBarSize
write SetCustomBarSize default 0;
end;
TCircledSeries=class(TChartSeries)
private
FCircleBackColor : TColor;
FCircled : Boolean;
FCircleGradient : TChartGradient;
FCustomXRadius : Integer;
FCustomYRadius : Integer;
FRotationAngle : Integer;
FXRadius : Integer;
FYRadius : Integer;
{ internal }
IBack3D : TView3DOptions;
FCircleWidth : Integer;
FCircleHeight : Integer;
FCircleXCenter : Integer;
FCircleYCenter : Integer;
FCircleRect : TRect;
IRotDegree : Double;
procedure SetCircleBackColor(Value:TColor);
Procedure SetCircled(Value:Boolean);
procedure SetCircleGradient(const Value: TChartGradient);
procedure SetCustomXRadius(Value:Integer);
procedure SetCustomYRadius(Value:Integer);
procedure SetOtherCustomRadius(IsXRadius:Boolean; Value:Integer);
protected
Procedure AdjustCircleRect;
Function CalcCircleBackColor:TColor;
Procedure CalcRadius;
Procedure DoBeforeDrawValues; override;
Procedure DrawCircleGradient; virtual;
Function HasBackColor:Boolean;
Procedure PrepareLegendCanvas( ValueIndex:Integer; Var BackColor:TColor;
Var BrushStyle:TBrushStyle); override;
Procedure SetActive(Value:Boolean); override;
Procedure SetParentChart(Const Value:TCustomAxisPanel); override;
Procedure SetParentProperties(EnableParentProps:Boolean); dynamic;
Procedure SetRotationAngle(const Value:Integer);
property CircleGradient:TChartGradient read FCircleGradient write SetCircleGradient;
public
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
Procedure AngleToPos( Const Angle,AXRadius,AYRadius:Double;
Var X,Y:Integer);
Procedure Assign(Source:TPersistent); override;
Function AssociatedToAxis(Axis:TChartAxis):Boolean; override;
Function PointToAngle(x,y:Integer):Double;
Procedure Rotate(const Angle:Integer);
Function UseAxis:Boolean; override;
{ read only properties }
property CircleBackColor:TColor read FCircleBackColor
write SetCircleBackColor default clTeeColor;
property CircleHeight:Integer read FCircleHeight;
property CircleRect:TRect read FCircleRect;
property CircleWidth:Integer read FCircleWidth;
property CircleXCenter:Integer read FCircleXCenter;
property CircleYCenter:Integer read FCircleYCenter;
property RotationAngle:Integer read FRotationAngle write SetRotationAngle
default 0;
property XRadius:Integer read FXRadius;
property YRadius:Integer read FYRadius;
published
property ColorSource;
property Cursor;
property Marks;
property ParentChart;
property DataSource;
property PercentFormat;
property SeriesColor;
property ShowInLegend;
property Title;
property ValueFormat;
property XLabelsSource;
{ events }
property AfterDrawValues;
property BeforeDrawValues;
property OnAfterAdd;
property OnBeforeAdd;
property OnClearValues;
property OnClick;
property OnDblClick;
property OnGetMarkText;
property OnMouseEnter;
property OnMouseLeave;
property Circled:Boolean read FCircled write SetCircled default False;
property CustomXRadius:Integer read FCustomXRadius write SetCustomXRadius default 0;
property CustomYRadius:Integer read FCustomYRadius write SetCustomYRadius default 0;
end;
TPieAngle=Packed Record
StartAngle : Double;
MidAngle : Double;
EndAngle : Double;
end;
TPieAngles=Array of TPieAngle;
TExplodedSlices=class(TList)
private
Procedure Put(Index,Value:Integer);
Function Get(Index:Integer):Integer;
public
OwnerSeries : TChartSeries;
property Value[Index:Integer]:Integer read Get write Put; default;
end;
TPieOtherStyle=(poNone,poBelowPercent,poBelowValue);
TPieOtherSlice=class(TPersistent)
private
FColor : TColor;
FLegend : TChartLegend;
FStyle : TPieOtherStyle;
FText : String;
FValue : Double;
FOwner : TChartSeries;
function GetLegend: TChartLegend;
Function GetText:String;
Function IsTextStored:Boolean;
procedure SetColor(Value:TColor);
procedure SetLegend(const Value: TChartLegend);
procedure SetStyle(Value:TPieOtherStyle);
procedure SetText(Const Value:String);
procedure SetValue(Const Value:Double);
public
Constructor Create(AOwner:TChartSeries);
Destructor Destroy; override;
Procedure Assign(Source:TPersistent); override;
published
property Color:TColor read FColor write SetColor default clTeeColor;
property Legend:TChartLegend read GetLegend write SetLegend;
property Style:TPieOtherStyle read FStyle write SetStyle default poNone;
property Text:String read GetText write SetText stored IsTextStored;
property Value:Double read FValue write SetValue;
end;
TPieShadow=class(TTeeShadow) { 5.02 }
published
property Color default Tee_PieShadowColor;
end;
TPieSeries=Class(TCircledSeries)
private
FAngleSize : Integer;
FAutoMarkPosition : Boolean;
FDark3D : Boolean;
FDarkPen : Boolean;
FDonutPercent : Integer;
FExplodedSlice : TExplodedSlices; { <-- Exploded slice % storage }
FExplodeBiggest : Integer;
FOtherSlice : TPieOtherSlice;
FShadow : TPieShadow;
FUsePatterns : Boolean;
ISortedSlice : Array of Integer;
Procedure CalcExplodeBiggest;
Procedure CalcExplodedOffset( ValueIndex:Integer;
Var OffsetX,OffsetY:Integer);
Function CompareSlice(A,B:Integer):Integer;
Procedure DisableRotation;
Function GetPiePen:TChartPen;
Function GetPieValues:TChartValueList;
Procedure PreparePiePen(ValueIndex:Integer);
procedure RemoveOtherSlice;
Procedure SetAngleSize(Value:Integer);
Procedure SetAutoMarkPosition(Value:Boolean);
Procedure SetDark3D(Value:Boolean);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?