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

📄 chart.pas

📁 TeeChart7Source 控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
			       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}
     DsgnIntf,
     {$ENDIF}
     Math, 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
  begin
    with ParentChart do
    begin
      P[0]:=Canvas.Calculate3DPosition(APos1, ChartRect.Top, 0);
      P[1]:=Canvas.Calculate3DPosition(APos1, ChartRect.Top, Width3D);
      P[2]:=Canvas.Calculate3DPosition(APos1, APos2, Width3D);
      P[3]:=Canvas.Calculate3DPosition(APos1, APos2, 0);
    end;

    if Transparency>0 then // 5.03
       result:=ParentChart.Canvas.BeginBlending(RectFromPolygon(P,4),Transparency);

    if HasGradient then
    begin
      Gradient.Draw(ParentChart.Canvas,P);
      ParentChart.Canvas.Brush.Style:=bsClear;
    end;
  end;
end;

procedure TCustomChartWall.SetAutoHide(const Value: Boolean);
begin
  TTeePanelAccess(ParentChart).SetBooleanProperty(FAutoHide,Value);
end;

function TCustomChartWall.ShouldDraw: Boolean;
begin
  result:=TCustomChart(ParentChart).View3DWalls and Visible and (not AutoHide);
end;

{ TChartBackWall }
Constructor TChartBackWall.Create(AOwner: TCustomTeePanel);
begin
  inherited;
  InitColor(clSilver);
  FDefaultTransparent:=True;
  Transparent:=True;
end;

{ TChartTitle }
Constructor TChartTitle.Create(AOwner: TCustomTeePanel);
Begin
  inherited;
  IOnTop:=True;

  FAlignment:=taCenter;
  FAdjustFrame:=True;
  FText:=TStringList.Create;
  TStringList(FText).OnChange:=AOwner.CanvasChanged;
  { inherited }
  Transparent:=True;
  Font.Color:=clBlue;
  TTeeFontAccess(Font).IDefColor:=clBlue;
end;

Destructor TChartTitle.Destroy;
Begin
  FText.Free;
  inherited;
end;

Procedure TChartTitle.Assign(Source:TPersistent);
Begin
  if Source is TChartTitle then
  With TChartTitle(Source) do
  Begin
    Self.FAdjustFrame  := FAdjustFrame;
    Self.FAlignment    := FAlignment;
    Self.Text          := FText;
  end;
  inherited;
end;

Function TChartTitle.Clicked(x,y:Integer):Boolean;
begin
  result:=Visible and PointInRect(ShapeBounds,x,y);
end;

procedure TChartTitle.DrawTitle;
var tmpXPosTitle  : Integer;
    tmpMargin     : Integer;
    FontH         : Integer;
    tmpFrameWidth : Integer;

  Procedure DrawTitleLine(AIndex:Integer);
  Var St   : String;
      APos : Integer;
  Begin { draw a title text line }
    St:=Text[AIndex];
    APos:=AIndex*FontH+tmpFrameWidth;
    if IOnTop then Inc(APos,ShapeBounds.Top)
              else APos:=ShapeBounds.Bottom-FontH-APos;

    if Alignment=taRightJustify then
       tmpXPosTitle:=ShapeBounds.Right-ParentChart.Canvas.TextWidth(St)-(tmpMargin div 2)
    else
    if Alignment=taCenter then
       tmpXPosTitle:=((ShapeBounds.Left+ShapeBounds.Right) div 2)-(ParentChart.Canvas.TextWidth(St) div 2);

    ParentChart.Canvas.TextOut(tmpXPosTitle,APos,St);
  end;

Var t               : Integer;
    tmpMaxWidth     : Integer;
    tmp             : Integer;
    tmpFrameVisible : Boolean;
    {$IFDEF CLR}
    tmpR            : TRect;
    {$ENDIF}
Begin
  if Visible and (Text.Count>0) then
  begin
    { calculate title shape margin }
    tmpFrameVisible:=Frame.Visible and (Frame.Color<>clTeeColor);
    if tmpFrameVisible then tmpFrameWidth:=Frame.Width
                       else tmpFrameWidth:=0;

    if Bevel<>bvNone then tmpFrameWidth:=BevelWidth;

    { apply title margins }
    if not FCustomPosition then
    begin
      ShapeBounds:=ParentChart.ChartRect;
      if IOnTop then ShapeBounds.Top:=ShapeBounds.Top+tmpFrameWidth;
    end;

    { prepare title font }
    With ParentChart.Canvas do
    begin
      AssignFont(Self.Font);
      TextAlign:=TA_LEFT;
      FontH:=FontHeight;
    end;

    { autosize title height on number of text lines }

⌨️ 快捷键说明

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