📄 series.pas
字号:
out X,Y:Integer);
Procedure Assign(Source:TPersistent); override;
Function AssociatedToAxis(Axis:TChartAxis):Boolean; override;
Function PointToAngle(x,y:Integer):Double;
Function PointToRadius(x,y: Integer): Double; // 7.02
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;
property Shadow:TCircledShadow read FShadow write SetShadow;
end;
TPieAngle=Packed Record
StartAngle : Double;
MidAngle : Double;
EndAngle : Double;
end;
TPieAngles=Array of TPieAngle;
TSliceValueList=class(TList)
private
Function Get(Index:Integer):Integer;
Procedure Put(Index,Value:Integer);
protected
OwnerSeries : TChartSeries;
public
{$IFNDEF D6}
procedure Assign(Source:TList);
{$ENDIF}
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;
TPieMarks=class(TPersistent)
private
FLegSize : Integer;
FVertCenter : Boolean;
IParent : TChartSeries;
procedure SetLegSize(const Value:Integer);
procedure SetVertCenter(const Value:Boolean);
public
Procedure Assign(Source:TPersistent); override;
published
property VertCenter:Boolean read FVertCenter write SetVertCenter default False;
property LegSize:Integer read FLegSize write SetLegSize default 0;
end;
TMultiPie=(mpAutomatic, mpDisabled);
TPieSeries=class(TCircledSeries)
private
FAngleSize : Integer;
FAutoMarkPosition : Boolean;
FDark3D : Boolean;
FDarkPen : Integer;
FDonutPercent : Integer;
FExplodedSlice : TSliceValueList; { <-- Exploded slice % storage }
FExplodeBiggest : Integer;
FMultiPie : TMultiPie; // v7.0
FOtherSlice : TPieOtherSlice;
FPieMarks : TPieMarks;
FSliceHeights : TSliceValueList; { <-- Slice Heights % storage }
FUsePatterns : Boolean;
ISortedSlice : Array of Integer;
IOldChartRect : TRect;
Procedure CalcExplodeBiggest;
Function CompareSlice(A,B:Integer):Integer;
Procedure DisableRotation;
Function GetPiePen:TChartPen;
Function GetPieValues:TChartValueList;
function PieCount:Integer;
Procedure PreparePiePen(ValueIndex:Integer);
procedure RemoveOtherSlice;
Procedure SetAngleSize(Value:Integer);
Procedure SetAutoMarkPosition(Value:Boolean);
Procedure SetDark3D(Value:Boolean);
procedure SetDarkPen(const Value: Integer);
procedure SetExplodeBiggest(Value:Integer);
procedure SetMultiPie(const Value:TMultiPie);
procedure SetOtherSlice(Value:TPieOtherSlice);
Procedure SetPieMarks(const Value:TPieMarks);
Procedure SetPieValues(Value:TChartValueList);
procedure SetUsePatterns(Value:Boolean);
Function SliceBrushStyle(ValueIndex:Integer):TBrushStyle;
Function SliceEndZ(ValueIndex:Integer):Integer;
Procedure SwapSlice(a,b:Integer);
protected
FAngles : TPieAngles;
IsExploded : Boolean;
Procedure AddSampleValues(NumValues:Integer; Sequential:Boolean=False); override;
Procedure CalcAngles;
Procedure CalcExplodedOffset( ValueIndex:Integer;
out OffsetX,OffsetY:Integer);
Procedure CalcExplodedRadius(ValueIndex:Integer; out AXRadius,AYRadius:Integer);
Procedure CalcFirstLastVisibleIndex; override;
procedure CalcSelectionPos(ValueIndex:Integer; out X,Y:Integer); override;
Procedure CalcZOrder; override; // 7.0
procedure CheckAngles;
Procedure CheckOtherSeriesMarks; override; // 6.02
Procedure ClearLists; override;
class Procedure CreateSubGallery(AddSubChart:TChartSubGalleryProc); override;
procedure DoAfterDrawValues; override;
procedure DoBeforeDrawChart; override;
procedure DoBeforeDrawValues; override;
procedure DrawAllValues; override;
Procedure DrawLegendShape(ValueIndex:Integer; Const Rect:TRect); override;
Procedure DrawMark( ValueIndex:Integer; Const St:String;
APosition:TSeriesMarkPosition); override;
Procedure DrawPie(ValueIndex:Integer); virtual;
procedure DrawValue(ValueIndex:Integer); override;
Procedure GalleryChanged3D(Is3D:Boolean); override;
class Function GetEditorClass:String; override;
Procedure InitCustom3DOptions; override;
Function MoreSameZOrder:Boolean; override; // 7.0
Procedure PrepareForGallery(IsEnabled:Boolean); override;
Procedure PrepareLegendCanvas( ValueIndex:Integer; var BackColor:TColor;
var BrushStyle:TBrushStyle); override;
procedure SetDonutPercent(Value:Integer);
Procedure SetParentChart(Const Value:TCustomAxisPanel); override;
class Procedure SetSubGallery(ASeries:TChartSeries; Index:Integer); override;
procedure WriteData(Stream: TStream); override;
public
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
Function AddPie(Const AValue:Double; Const ALabel:String='';
AColor:TColor=clTeeColor):Integer;
Procedure Assign(Source:TPersistent); override;
Function BelongsToOtherSlice(ValueIndex:Integer):Boolean;
Function CalcClickedPie(x,y:Integer; Exploded:Boolean=True):Integer; // 7.07
Function CalcXPos(ValueIndex:Integer):Integer; override;
Procedure CheckOrder; override;
procedure Clear; override;
Function Clicked(x,y:Integer):Integer; override;
Function CountLegendItems:Integer; override;
procedure Delete(ValueIndex:Integer); override; // 7.0
Function LegendToValueIndex(LegendIndex:Integer):Integer; override;
Function MaxXValue:Double; override;
Function MinXValue:Double; override;
Function MaxYValue:Double; override;
Function MinYValue:Double; override;
Function NumSampleValues:Integer; override;
procedure SwapValueIndex(a,b:Integer); override;
property Angles:TPieAngles read FAngles;
property DonutPercent:Integer read FDonutPercent write SetDonutPercent;
property ExplodedSlice:TSliceValueList read FExplodedSlice;
property SliceHeight:TSliceValueList read FSliceHeights;
published
property Active;
property AngleSize:Integer read FAngleSize write SetAngleSize default 360;
property AutoMarkPosition:Boolean read FAutoMarkPosition write SetAutoMarkPosition default True;
property CircleBackColor;
property ColorEachPoint default True;
property Dark3D:Boolean read FDark3D write SetDark3D default True;
property DarkPen:Integer read FDarkPen write SetDarkPen default 0;
property ExplodeBiggest:Integer read FExplodeBiggest write SetExplodeBiggest default 0;
property Gradient:TChartGradient read FCircleGradient write SetCircleGradient;
property MultiPie:TMultiPie read FMultiPie write SetMultiPie default mpAutomatic;
property OtherSlice:TPieOtherSlice read FOtherSlice write SetOtherSlice;
property PieMarks:TPieMarks read FPieMarks write SetPieMarks;
property PiePen:TChartPen read GetPiePen write SetPen;
property PieValues:TChartValueList read GetPieValues write SetPieValues;
property RotationAngle;
property UsePatterns:Boolean read FUsePatterns write SetUsePatterns default False;
end;
TFastLineSeries=class(TCustomLineSeries)
private
FAutoRepaint : Boolean;
FDrawAll : Boolean;
{$IFDEF TEEOCX}
FExpandAxis : Integer; // 7.01
{$ENDIF}
FFastPen : Boolean;
FIgnoreNulls : Boolean; // 6.0
FInvertedStairs : Boolean; // 6.0
FStairs : Boolean; // 6.0
{$IFNDEF CLX}
DCPEN : HGDIOBJ;
{$ENDIF}
{ internal }
OldX : Integer;
OldY : Integer;
procedure DoMove(X,Y:Integer);
Procedure SetDrawAll(Const Value:Boolean);
procedure SetFastPen(const Value: Boolean);
procedure SetIgnoreNulls(const Value: Boolean);
procedure SetInvertedStairs(const Value: Boolean);
procedure SetStairs(const Value: Boolean);
protected
Procedure CalcHorizMargins(var LeftMargin,RightMargin:Integer); override;
Procedure CalcPosition(ValueIndex:Integer; out x,y:Integer);
Procedure CalcVerticalMargins(var TopMargin,BottomMargin:Integer); override;
class Procedure CreateSubGallery(AddSubChart:TChartSubGalleryProc); override;
procedure DrawAllValues; override;
Procedure DrawLegendShape(ValueIndex:Integer; Const Rect:TRect); override;
Procedure DrawMark( ValueIndex:Integer; Const St:String;
APosition:TSeriesMarkPosition); override;
procedure DrawValue(ValueIndex:Integer); override;
class Function GetEditorClass:String; override;
Procedure NotifyNewValue(Sender:TChartSeries; ValueIndex:Integer); override; // 7.0 moved from public
procedure PrepareCanvas;
Procedure PrepareLegendCanvas( ValueIndex:Integer; var BackColor:TColor;
var BrushStyle:TBrushStyle); override;
Procedure SetPen(Const Value:TChartPen); override;
Procedure SetSeriesColor(AColor:TColor); override;
class Procedure SetSubGallery(ASeries:TChartSeries; Index:Integer); override;
public
Constructor Create(AOwner: TComponent); override;
Procedure Assign(Source:TPersistent); override;
Function Clicked(x,y:Integer):Integer; override;
property FastPen:Boolean read FFastPen write SetFastPen default False;
published
property Active;
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 AutoRepaint:Boolean read FAutoRepaint write FAutoRepaint default True;
{$IFDEF TEEOCX}
property ExpandAxis:Integer read FExpandAxis write FExpandAxis default 25;
{$ENDIF}
property DrawAllPoints:Boolean read FDrawAll write SetDrawAll default True;
// obsolete and redundant, please use TreatNulls property:
property IgnoreNulls:Boolean read FIgnoreNulls write SetIgnoreNulls default True;
property InvertedStairs:Boolean read FInvertedStairs write SetInvertedStairs default False;
property LinePen;
property Stairs:Boolean read FStairs write SetStairs default False;
property TreatNulls default tnIgnore;
property XValues;
property YValues;
end;
Const
bsCylinder=bsCilinder; { <-- better spelling... }
// Calls RegisterTeeSeries for each "standard" series type:
// Line, Bar, Pie, FastLine, HorizBar, Area, Point and HorizLine
Procedure RegisterTeeStandardSeries;
Procedure TeePointerDrawLegend(Pointer:TSeriesPointer; AColor:TColor;
Const Rect:TRect; DrawPen:Boolean;
AStyle:TSeriesPointerStyle);
implementation
Uses Math, TeeConst;
Function GetDefaultPattern(const PatternIndex:Integer):TBrushStyle;
Const MaxDefaultPatterns = 6;
PatternPalette : Array[1..MaxDefaultPatterns] of TBrushStyle=
( bsHorizontal,
bsVertical,
bsFDiagonal,
bsBDiagonal,
bsCross,
bsDiagCross
);
Begin
result:=PatternPalette[1+(PatternIndex mod MaxDefaultPatterns)];
End;
Procedure TeePointerDrawLegend(Pointer:TSeriesPointer; AColor:TColor;
Const Rect:TRect; DrawPen:Boolean;
AStyle:TSeriesPointerStyle);
var tmpHoriz : Integer;
tmpVert : Integer;
begin
if Assigned(Pointer.ParentChart) then
begin
Pointer.PrepareCanvas(Pointer.ParentChart.Canvas,AColor);
with TCustomChart(Pointer.ParentChart) do
if not Legend.Symbol.DefaultPen then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -