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

📄 bigcandl.pas

📁 TeeChart 7.0 With Source在Delphi 7.0中的安装
💻 PAS
字号:
{**********************************************}
{   TBigCandleSeries (TCandleSeries)           }
{   Copyright (c) 1996-2005 by David Berneda   }
{**********************************************}
unit BigCandl;
{$I TeeDefs.inc}

interface

uses {$IFDEF CLR}
     Classes,
     {$ELSE}
     {$IFNDEF LINUX}
     Windows, Messages,
     {$ENDIF}
     SysUtils, Classes,
     {$IFDEF CLX}
     QGraphics, QControls, QForms, QDialogs,
     {$ELSE}
     Graphics, Controls, Forms, Dialogs,
     {$ENDIF}
     {$ENDIF}
     TeEngine, Series, OHLChart, CandleCh;

type
  TBigCandleSeries = class(TCandleSeries)
  private
    { Private declarations }
    FHorizGap : Integer;
    FVertGap  : Integer;
  protected
    { Protected declarations }
    Procedure DrawMark( ValueIndex:Integer; Const St:String;
                        APosition:TSeriesMarkPosition); override;
    Procedure SetHorizGap(Value:Integer);
    Procedure SetVertGap(Value:Integer);
  public
    { Public declarations }
    Constructor Create(AOwner: TComponent); override;
  published
    { Published declarations }
    property HorizGap:Integer read FHorizGap write SetHorizGap;
    property VertGap:Integer read FVertGap write SetVertGap;
  end;

implementation

Uses {$IFDEF CLR}
     SysUtils,
     {$ENDIF}
     Chart, TeCanvas, TeeProCo;

{ TBigCandleSeries }
Constructor TBigCandleSeries.Create(AOwner: TComponent);
begin
  inherited;
  FHorizGap:=20;
  FVertGap:=6;
  Marks.Visible:=True;
  Marks.Callout.Length:=0;
end;

Procedure TBigCandleSeries.SetHorizGap(Value:Integer);
begin
  SetIntegerProperty(FHorizGap,Value);
end;

Procedure TBigCandleSeries.SetVertGap(Value:Integer);
begin
  SetIntegerProperty(FVertGap,Value);
end;

Procedure TBigCandleSeries.DrawMark( ValueIndex:Integer; Const St:String;
                                     APosition:TSeriesMarkPosition);

  Procedure InternalDrawMark(Const AValue:Double);
  begin
    inherited DrawMark(ValueIndex,FormatFloat(ValueFormat,AValue),APosition);
  end;

Var tmpX           : Integer;
    tmpHorizOffset : Integer;
    tmpVertOffset  : Integer;
begin
  With APosition do
  begin
    tmpHorizOffset:=(Width div 2)+ FHorizGap ;  { <-- custom horiz "gap" }
    tmpVertOffset :=Height + FVertGap;       { <-- custom vert "gap" }

    tmpX:=LeftTop.X;

    { Open Price Mark }
    With LeftTop do
    begin
      Y:=CalcYPosValue(OpenValues.Value[ValueIndex])-(Height div 2);
      X:=tmpX-tmpHorizOffset;
    end;
    InternalDrawMark(OpenValues.Value[ValueIndex]);

    { Close Price Mark }
    With LeftTop do
    begin
      Y:=CalcYPosValue(CloseValues.Value[ValueIndex])-(Height div 2);
      X:=tmpX+tmpHorizOffset;
    end;
    InternalDrawMark(CloseValues.Value[ValueIndex]);

    { High Price Mark }
    LeftTop.Y:=CalcYPosValue(HighValues.Value[ValueIndex])-tmpVertOffset;
    InternalDrawMark(HighValues.Value[ValueIndex]);

    { Low Price Mark }
    LeftTop.Y:=CalcYPosValue(LowValues.Value[ValueIndex])+tmpVertOffset-Height;
    InternalDrawMark(LowValues.Value[ValueIndex]);
  end;
end;

initialization
  RegisterTeeSeries( TBigCandleSeries, {$IFNDEF CLR}@{$ENDIF}TeeMsg_GalleryBigCandle,
                                       {$IFNDEF CLR}@{$ENDIF}TeeMsg_GallerySamples, 1 );
finalization
  UnRegisterTeeSeries([TBigCandleSeries]);
end.

⌨️ 快捷键说明

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