📄 chart.pas
字号:
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}
{$IFDEF CLX}
property Bitmap;
{$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;
{$IFDEF K3}
property OnMouseEnter;
property OnMouseLeave;
{$ELSE}
{$IFDEF D10}
property OnMouseEnter;
property OnMouseLeave;
{$ENDIF}
{$ENDIF}
property OnMouseMove;
property OnMouseUp;
property OnResize;
{$IFNDEF CLX}
{$IFNDEF LCL}
property OnCanResize;
{$ENDIF}
{$ENDIF}
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnConstrainedResize;
{$IFNDEF CLX}
property OnDockDrop;
property OnDockOver;
property OnEndDock;
property OnGetSiteInfo;
property OnStartDock;
property OnUnDock;
{$ENDIF}
end;
TTeeSeriesTypes=class(TList)
private
Function Get(Index:Integer):TTeeSeriesType;
public
Procedure Clear; override;
Function Find(ASeriesClass:TChartSeriesClass):TTeeSeriesType;
property Items[Index:Integer]:TTeeSeriesType read Get; default;
end;
TTeeToolTypes=class(TList)
private
Function Get(Index:Integer):TTeeCustomToolClass;
public
property Items[Index:Integer]:TTeeCustomToolClass read Get; default;
end;
{$IFNDEF CLX}
TTeeDragObject = class(TDragObject)
private
FPart: TChartClickedPart;
protected
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
public
constructor Create(Const APart: TChartClickedPart);
property Part: TChartClickedPart read FPart;
end;
{$ENDIF}
TColorPalettes=class(TStringList)
public
class procedure ApplyPalette(Chart:TCustomAxisPanel; Index:Integer); overload; {$IFDEF CLR}static;{$ENDIF}
class procedure ApplyPalette(Chart:TCustomAxisPanel; const Palette:Array of TColor); overload; {$IFDEF CLR}static;{$ENDIF}
end;
var ColorPalettes : TColorPalettes=nil;
TeeSeriesTypes: TTeeSeriesTypes=nil; { List of Series types }
TeeToolTypes: TTeeToolTypes=nil; { List of Tool types }
{ Adds a new Series component definition for the Gallery }
{ Setting ANumGallerySeries to zero makes the Series to not appear on the
Gallery. }
Procedure RegisterTeeSeries( ASeriesClass:TChartSeriesClass;
ADescription,AGalleryPage:PString;
ANumGallerySeries : Integer ); overload;
// Same as above, at default "Standard" tab with NumSeries = 2
Procedure RegisterTeeSeries( ASeriesClass:TChartSeriesClass;
ADescription:PString); overload;
{ Adds a new Function component definition for the Gallery }
Procedure RegisterTeeFunction( AFunctionClass:TTeeFunctionClass;
ADescription,AGalleryPage:PString;
ANumGallerySeries : Integer=1 );
{ Adds a new Function component to the basic functions gallery }
Procedure RegisterTeeBasicFunction( AFunctionClass:TTeeFunctionClass;
ADescription:PString);
{ Adds a new Series & Function components definition for the Gallery }
Procedure RegisterTeeSeriesFunction( ASeriesClass:TChartSeriesClass;
AFunctionClass:TTeeFunctionClass;
ADescription,AGalleryPage:PString;
ANumGallerySeries : Integer );
{ Removes Series from Gallery }
Procedure UnRegisterTeeSeries(Const ASeriesList:Array of TChartSeriesClass);
{ Removes Functions from Gallery }
Procedure UnRegisterTeeFunctions(Const AFunctionList:Array of TTeeFunctionClass);
{ Assigns all Series properties from Old to New. (Data values ARE assigned). }
Procedure AssignSeries(Var OldSeries,NewSeries:TChartSeries);
{ Creates a new "class" TeeFunction and sets its ParentSeries to ASeries }
Function CreateNewTeeFunction( ASeries:TChartSeries;
AClass:TTeeFunctionClass):TTeeFunction;
{ Creates a new "class" TChartSeries and sets its ParentChart to AChart }
Function CreateNewSeries( AOwner:TComponent;
AChart:TCustomAxisPanel;
AClass:TChartSeriesClass;
AFunctionClass:TTeeFunctionClass=nil):TChartSeries;
// Creates a new Series that is a copy of ASeries.
Function CloneChartSeries(ASeries:TChartSeries):TChartSeries; overload;
Function CloneChartSeries(ASeries:TChartSeries; AChart:TCustomAxisPanel):TChartSeries; overload;
Function CloneChartSeries(ASeries:TChartSeries; AOwner:TComponent; AChart:TCustomAxisPanel):TChartSeries; overload;
Function ChangeSeriesType(var ASeries:TChartSeries; NewType:TChartSeriesClass ):TChartSeries;
procedure ChangeAllSeriesType( AChart:TCustomChart; AClass:TChartSeriesClass );
Function GetNewSeriesName(AOwner:TComponent):TComponentName;
Procedure RegisterTeeTools(Tools:Array of TTeeCustomToolClass);
Procedure UnRegisterTeeTools(Tools:Array of TTeeCustomToolClass);
{ Returns the name of a Series in it磗 "gallery" style:
TLineSeries returns "Line"
TPieSeries returns "Pie"
etc.
}
Function GetGallerySeriesName(ASeries:TChartSeries):String;
{ Draws the Series "Legend" on the specified rectangle and Canvas }
Procedure PaintSeriesLegend(ASeries:TChartSeries; ACanvas:TCanvas; Const R:TRect;
ReferenceChart:TCustomChart=nil); // 7.0
var
TeePageNumToolClass : TTeeCustomToolClass = nil;
type
TChartTheme=class(TPersistent)
public
Chart : TCustomChart;
constructor Create(AChart: TCustomChart); {$IFDEF CLR}overload;{$ENDIF} virtual;
procedure Apply; virtual; // BCB does not accept "abstract;"
function Description:string; virtual;
end;
TChartThemeClass=class of TChartTheme;
TTeeThemeSelectorProc=Function(Chart:TCustomChart):TChartThemeClass;
var TeeThemeSelectorHook : TTeeThemeSelectorProc=nil;
TeeNewChartHook : TTeeThemeSelectorProc=nil;
const
ExcelPalette:Array[0..21] of TColor=
(
$FF9999,
$663399,
$CCFFFF,
$FFFFCC,
$660066,
$8080FF,
$CC6600,
$FFCCCC,
$800000,
$FF00FF,
$00FFFF,
$FFFF00,
$800080,
$000080,
$808000,
$FF0000,
$FFCC00,
$FFFFCC,
$CCFFCC,
$00FFFF,
$FFCC99,
$CC99FF
);
VictorianPalette:Array[0..10] of TColor=
(
$A1A55D,
$3153C4,
$0996E7,
$4AE8F6,
$A7A2B1,
$84A7C9,
$51798C,
$B7CDD8,
$536508,
$7BD8F7,
$846401
);
PastelsPalette:Array[0..13] of TColor=
(
$FFFFCC,
$CCFFFF,
$FFCCCC,
$CCCC00,
$CCCCCC,
$999900,
$999999,
$CCCCFF,
$66CCFF,
$FFCCCC,
$9999FF,
$99FFFF,
$FFCC99,
$CCFFCC
);
SolidPalette:Array[0..7] of TColor=
(
$FF0000,
$0000FF,
$00FF00,
$00CCFF,
$404040,
$00FFFF,
$C000FF,
$FFFFFF
);
ClassicPalette:Array[0..11] of TColor=
(
$FF0000,
$00FF00,
$FFFF00,
$0000FF,
$FF00FF,
$00FFFF,
$800000,
$008000,
$808000,
$000080,
$800080,
$008080
);
WebPalette:Array[0..8] of TColor=
(
$00A5FF,
$CE0000,
$00CE00,
$40FFFF,
$FFFF40,
$FF40FF,
$0040FF,
$A58080,
$408080
);
ModernPalette:Array[0..13] of TColor=
(
$6699FF,
$6666FF,
$FFCC99,
$669966,
$99CCCC,
$CC6699,
$6666CC,
$99CCFF,
$FF6699,
$CCCCCC,
$CCFF66,
$FF9966,
$996699,
$FFCCCC
);
RainbowPalette:Array[0..24] of TColor=
(
$000099,
$0000C3,
$0000EE,
$001AFF,
$0046FF,
$0073FF,
$009FFF,
$00CBFF,
$00F7FF,
$08F4E3,
$11E7C3,
$1BDAA3,
$25CD83,
$2EC063,
$38B342,
$42A622,
$4B9A02,
$6A870C,
$8A751A,
$AA6328,
$CB5036,
$EB3E44,
$FF2A61,
$FF1596,
$FF00CC
);
WindowsXPPalette:Array[0..12] of TColor=
(
$FE9B82,
$24D1FC,
$0DBC7C,
$2F85FD,
$FCFEFD,
$214EE2,
$D63829,
$0094B7,
$00865A,
$0046D2,
$FAE5D3,
$D8D8D8,
$7B715F
);
implementation
Uses {$IFNDEF D5}
{$IFNDEF LCL}
DsgnIntf,
{$ENDIF}
{$ENDIF}
{$IFDEF LCL}
GraphType,
{$ENDIF}
Math, TeeHtml, TeeConst;
{ TCustomChartWall }
Constructor TCustomChartWall.Create(AOwner:TCustomTeePanel);
Begin
inherited;
FDark3D:=True;
Color:=clTeeColor;
DefaultColor:=clTeeColor;
End;
Function TCustomChartWall.IsColorStored:Boolean;
begin
result:=Color<>DefaultColor;
end;
Procedure TCustomChartWall.Assign(Source:TPersistent);
Begin
if Source is TCustomChartWall then
With TCustomChartWall(Source) do
Begin
Self.FAutoHide:=AutoHide;
Self.FDark3D:=Dark3D;
Self.FSize:=Size;
end;
inherited;
End;
Function TCustomChartWall.ApplyDark3D:Boolean;
begin
result:=(Brush.Style<>bsClear) and
((Brush.Bitmap=nil) {$IFDEF CLX}or (Brush.Bitmap.Empty){$ENDIF}) and
Dark3D;
end;
Function TCustomChartWall.GetPen:TChartPen;
begin
result:=Frame;
end;
Procedure TCustomChartWall.SetPen(Value:TChartPen);
Begin
Frame:=Value;
end;
type
TTeePanelAccess=class(TCustomTeePanel);
Procedure TCustomChartWall.SetSize(Value:Integer);
Begin
TTeePanelAccess(ParentChart).SetIntegerProperty(FSize,Value);
End;
Procedure TCustomChartWall.SetDark3D(Value:Boolean);
begin
TTeePanelAccess(ParentChart).SetBooleanProperty(FDark3D,Value);
end;
procedure TCustomChartWall.InitColor(AColor: TColor);
begin
Color:=AColor;
DefaultColor:=AColor;
end;
type
TTeeFontAccess=class(TTeeFont);
function TCustomChartWall.HasGradient: Boolean;
begin
result:=Assigned(FGradient) and FGradient.Visible;
end;
Function TCustomChartWall.TryDrawWall(APos1,APos2:Integer):TTeeBlend;
var P : TFourPoints;
begin
result:=nil;
if not Transparent then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -