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

📄 teengine.pas

📁 TeeChart Pro v7.04,Delphi图表专用控件,可以生成多种图表
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    FSeries      : TChartSeries;
    FPositions   : TSeriesMarksPositions;
    FSymbol      : TSeriesMarksSymbol;
    FZPosition   : Integer;

    function GetArrowLength: Integer;
    function GetArrowPen: TChartArrowPen;
    Function GetBackColor:TColor;
    Function GetCallout:TMarksCallout;
    function GetItem(Index:Integer):TMarksItem;
    Function GetSymbol: TSeriesMarksSymbol;
    Procedure InternalDraw(Index:Integer; AColor:TColor; Const St:String; APosition:TSeriesMarkPosition);
    procedure ReadItems(Stream: TStream);
    Procedure SetAngle(Value:Integer);
    procedure SetCallout(const Value: TMarksCallout);
    Procedure SetArrowPen(const Value:TChartArrowPen);
    Procedure SetArrowLength(Value:Integer);
    Procedure SetBackColor(Value:TColor);
    Procedure SetClip(Value:Boolean);
    Procedure SetDrawEvery(Value:Integer);
    Procedure SetMultiline(Value:Boolean);
    Procedure SetStyle(Value:TSeriesMarksStyle);
    procedure SetSymbol(const Value: TSeriesMarksSymbol);
    procedure WriteItems(Stream: TStream);
  protected
    Procedure AntiOverlap(First, ValueIndex:Integer; APosition:TSeriesMarkPosition);
    Procedure ConvertTo2D(Point:TPoint; var P:TPoint);
    procedure DefineProperties(Filer: TFiler); override;
    Function GetGradientClass:TChartGradientClass; override;
    Procedure InitShadow(AShadow:TTeeShadow); override;
    Function MarkItem(ValueIndex:Integer):TTeeCustomShape;
    procedure SetParent(Value:TCustomTeePanel); override;
    Function TextWidth(ValueIndex:Integer):Integer;
    Procedure UsePosition(Index:Integer; Var MarkPosition:TSeriesMarkPosition);
  public
    Constructor Create(AOwner:TChartSeries); overload;
    Destructor Destroy; override;

    Procedure ApplyArrowLength(APosition:TSeriesMarkPosition);
    Procedure Assign(Source:TPersistent); override;
    procedure Clear;
    Function Clicked(X,Y:Integer):Integer;
    Procedure DrawText(Const R:TRect; Const St:String);

    property Item[Index:Integer]:TMarksItem read GetItem; default;
    property Items:TMarksItems read FItems;
    property ParentSeries:TChartSeries read FSeries;
    property Positions:TSeriesMarksPositions read FPositions;
    procedure ResetPositions;
    property ZPosition : Integer read FZPosition write FZPosition;
  published
    property Angle:Integer read FAngle write SetAngle default 0;
    property Arrow:TChartArrowPen read GetArrowPen write SetArrowPen; // obsolete
    property ArrowLength:Integer read GetArrowLength write SetArrowLength stored False; // obsolete
    property Callout:TMarksCallout read GetCallout write SetCallout;  // 6.0
    property BackColor:TColor read GetBackColor write SetBackColor default ChartMarkColor;
    property Bevel;  { 5.01 }
    property BevelWidth;  { 5.01 }
    property Brush;
    property Clip:Boolean read FClip write SetClip default False;
    property Color default ChartMarkColor;
    property DrawEvery:Integer read FDrawEvery write SetDrawEvery default 1;
    property Font;
    property Frame;
    property Gradient;
    property MultiLine:Boolean read FMultiLine write SetMultiLine default False;
    property Shadow;
    property ShapeStyle;
    property Style:TSeriesMarksStyle read FMarkerStyle
                                     write SetStyle default smsLabel;
    property Symbol:TSeriesMarksSymbol read GetSymbol write SetSymbol;
    property Transparency; { 5.01 }
    property Transparent;
    property Visible;
  end;

  TSeriesOnBeforeAdd=Function(Sender:TChartSeries):Boolean of object;
  TSeriesOnAfterAdd=Procedure(Sender:TChartSeries; ValueIndex:Integer) of object;
  TSeriesOnClear=Procedure(Sender:TChartSeries) of object;
  TSeriesOnGetMarkText=Procedure(Sender:TChartSeries; ValueIndex:Integer; Var MarkText:String) of object;

  TSeriesRecalcOptions=set of (rOnDelete, rOnModify, rOnInsert, rOnClear);

  TFunctionPeriodStyle=( psNumPoints, psRange );
  TFunctionPeriodAlign=( paFirst,paCenter,paLast );

  {$IFDEF CLR}
  [ToolBoxItem(False)]
  {$ENDIF}
  TTeeFunction=class(TComponent)
  private
    FPeriod      : Double;
    FPeriodStyle : TFunctionPeriodStyle;
    FPeriodAlign : TFunctionPeriodAlign;
    FParent      : TChartSeries;

    IUpdating    : Boolean;
    Procedure SetPeriod(Const Value:Double);
    Procedure SetParentSeries(AParent:TChartSeries);
    Procedure SetPeriodAlign(Value:TFunctionPeriodalign);
    Procedure SetPeriodStyle(Value:TFunctionPeriodStyle);
  protected
    CanUsePeriod     : Boolean;  // function uses Period property ?
    NoSourceRequired : Boolean;  // function requires source Series ?
    SingleSource     : Boolean;  // function allows more than one source ?
    HideSourceList   : Boolean;  // For single-source, allow select value-list ?

    Procedure AddFunctionXY(YMandatorySource:Boolean; const tmpX,tmpY:Double);
    Procedure CalculatePeriod( Source:TChartSeries;
                               Const tmpX:Double;
                               FirstIndex,LastIndex:Integer); virtual;
    Procedure CalculateAllPoints(Source:TChartSeries; NotMandatorySource:TChartValueList); virtual;
    Procedure CalculateByPeriod(Source:TChartSeries; NotMandatorySource:TChartValueList); virtual;
    procedure Clear; dynamic;
    Procedure DoCalculation( Source:TChartSeries;
                             NotMandatorySource:TChartValueList); virtual;
    class Function GetEditorClass:String; virtual;
    Procedure InternalSetPeriod(Const APeriod:Double);
    Function IsValidSource(Value:TChartSeries):Boolean; dynamic;
    class Procedure PrepareForGallery(Chart:TCustomAxisPanel); virtual;
    {$IFNDEF CLR}
    procedure SetParentComponent(Value: TComponent); override;
    {$ENDIF}
    Function ValueList(ASeries:TChartSeries):TChartValueList;
  public
    Constructor Create(AOwner: TComponent); override;
    Procedure Assign(Source:TPersistent); override;

    procedure AddPoints(Source:TChartSeries); dynamic;
    procedure BeginUpdate;
    Function Calculate(SourceSeries:TChartSeries; First,Last:Integer):Double; virtual;
    Function CalculateMany(SourceSeriesList:TList; ValueIndex:Integer):Double; virtual;
    procedure EndUpdate;
    function GetParentComponent: TComponent; override;
    function HasParent: Boolean; override;
    property ParentSeries:TChartSeries read FParent write SetParentSeries;
    Procedure ReCalculate;
    {$IFDEF CLR}
    procedure SetParentComponent(Value: TComponent); override;
    {$ENDIF}
  published
    property Period:Double read FPeriod write SetPeriod;
    property PeriodAlign:TFunctionPeriodAlign read FPeriodAlign
                                              write SetPeriodAlign default paCenter;
    property PeriodStyle:TFunctionPeriodStyle read FPeriodStyle
                                              write SetPeriodStyle default psNumPoints;
  end;

  TTeeMovingFunction=class(TTeeFunction)
  protected
    Procedure DoCalculation( Source:TChartSeries;
                             NotMandatorySource:TChartValueList); override;
  public
    Constructor Create(AOwner:TComponent); override;
  published
    property Period;
  end;

  TChartValueLists=class {$IFDEF CLR}sealed{$ENDIF} (TList)
  private
    Function Get(Index:Integer):TChartValueList;
  public
    Procedure Clear; override;
    property ValueList[Index:Integer]:TChartValueList read Get; default;
  end;

  TChartSeriesStyle=set of ( tssIsTemplate,
                             tssDenyChangeType,
                             tssDenyDelete,
                             tssDenyClone,
                             tssIsPersistent,
                             tssHideDataSource );

  TCustomChartSeries=class(TCustomChartElement)
  private
    FShowInLegend : Boolean;
    FTitle        : String;
    FIdentifier   : String;  { DecisionCube }
    FStyle        : TChartSeriesStyle; { DecisionCube }
    procedure ReadIdentifier(Reader: TReader);
    procedure WriteIdentifier(Writer: TWriter);
    procedure ReadStyle(Reader: TReader);
    procedure WriteStyle(Writer: TWriter);

    Procedure RepaintDesigner;
    Procedure SetShowInLegend(Value:Boolean);
    Procedure SetTitle(Const Value:String);
  protected
    Procedure Added; dynamic;
    Procedure CalcHorizMargins(Var LeftMargin,RightMargin:Integer); virtual;
    Procedure CalcVerticalMargins(Var TopMargin,BottomMargin:Integer); virtual;
    procedure DefineProperties(Filer: TFiler); override;
    procedure DoBeforeDrawChart; virtual;
    Procedure GalleryChanged3D(Is3D:Boolean); dynamic;
    Procedure Removed; dynamic;
    Procedure SetActive(Value:Boolean); override;
  public
    Constructor Create(AOwner: TComponent); override;

    procedure Assign(Source:TPersistent); override;
    Function SameClass(tmpSeries:TChartSeries):Boolean;

    property ShowInLegend:Boolean read FShowInLegend write SetShowInLegend default True;
    property Title:String read FTitle write SetTitle;
    { DSS, hidden }
    property Identifier:String read FIdentifier write FIdentifier;
    property Style:TChartSeriesStyle read FStyle write FStyle default [];
  end;

  TSeriesRandomBounds=packed record
    tmpX,StepX,tmpY,MinY,DifY:Double;
  end;

  TTeeFunctionClass=class of TTeeFunction;

  {$IFDEF CLR}
  PString=string;
  {$ENDIF}

  TTeeSeriesType=class {$IFDEF CLR}sealed{$ENDIF} (TObject)
    SeriesClass      : TChartSeriesClass;
    FunctionClass    : TTeeFunctionClass;
    Description      : PString;
    GalleryPage      : PString;
    NumGallerySeries : Integer;
  end;

  TChartSubGalleryProc=Function(Const AName:String):TCustomAxisPanel of object;

  TLegendTextStyle=( ltsPlain,ltsLeftValue,ltsRightValue,
                     ltsLeftPercent,ltsRightPercent,ltsXValue,ltsValue,
                     ltsPercent,ltsXAndValue,ltsXAndPercent);

  TeeFormatFlags = (tfNoMandatory,tfColor,tfLabel,tfMarkPosition);
  TeeFormatFlag  = set of TeeFormatFlags;

  TLabelsList=class {$IFDEF CLR}sealed{$ENDIF} (TList)
  private
    Series : TChartSeries;
    Procedure DeleteLabel(ValueIndex:Integer);
    Function GetLabel(ValueIndex:Integer):String;
    Procedure SetLabel(ValueIndex:Integer; Const ALabel:String);
    Procedure InsertLabel(ValueIndex:Integer; Const ALabel:String);
  public
    procedure Assign(Source:TLabelsList);
    procedure Clear; override;
    Function IndexOfLabel(const ALabel:String; CaseSensitive:Boolean=True):Integer;
    property Labels[Index:Integer]:String read GetLabel write SetLabel; default;
  end;

  TDataSourcesList=class {$IFDEF CLR}sealed{$ENDIF} (TList)  // 6.02
  private
    Series : TChartSeries;
    function InheritedAdd(Value:TComponent):Integer;
    procedure InheritedClear;
  {$IFDEF D5}
  protected
    {$IFDEF CLR}
    procedure Notify(Instance:TObject; Action: TListNotification); override;
    {$ELSE}
    procedure Notify(Ptr: Pointer; Action: TListNotification); override;
    {$ENDIF}
  {$ENDIF}
  public
    function Add(Value:TComponent):Integer;
    procedure Clear; override;
  end;

  TChartSeries=class(TCustomChartSeries)
  private
    FColor              : TColor;
    FColorEachPoint     : Boolean;
    FColors             : TList;
    FColorSource        : String;
    FCursor             : TCursor;
    FDataSources        : TDataSourcesList;
    FDepth              : Integer;
    FGetHorizAxis       : TChartAxis;
    FGetVertAxis        : TChartAxis;
    FLabelsSource       : String;
    FLinkedSeries       : TCustomSeriesList;
    FMarks              : TSeriesMarks;
    FPercentFormat      : String;
    FTempDataSources    : TStringList;
    FValueFormat        : String;
    FValuesList         : TChartValueLists;
    FX                  : TChartValueList;
    FLabels             : TLabelsList;
    FY                  : TChartValueList;

    FHorizAxis          : THorizAxis;
    FCustomHorizAxis    : TChartAxis;
    FCustomVertAxis     : TChartAxis;
    FZOrder             : Integer;

    FVertAxis           : TVertAxis;
    FRecalcOptions      : TSeriesRecalcOptions;

    FTeeFunction        : TTeeFunction;

    { Private }
    IsMouseInside       : Boolean;
    ILabelOrder         : TChartListOrder;
    ISeriesColor        : TColor; // Color assigned when creating the Series.

    { Events }
    FAfterDrawValues    : TNotifyEvent;
    FBeforeDrawValues   : TNotifyEvent;
    FOnAfterAdd         : TSeriesOnAfterAdd;
    FOnBeforeAdd        : TSeriesOnBeforeAdd;
    FOnClearValues      : TSeriesOnClear;
    FOnClick            : TSeriesClick;
    FOnDblClick         : TSeriesClick;
    FOnGetMarkText      : TSeriesOnGetMarkText;
    FOnMouseEnter       : TNotifyEvent;
    FOnMouseLeave       : TNotifyEvent;

    Function CanAddRandomPoints:Boolean;
    Procedure ChangeInternalColor(Value:TColor);
    Function CompareLabelIndex(a,b:Integer):Integer;
    Function GetDataSource:TComponent;
    Function GetZOrder:Integer;
    Procedure GrowColors;
    Function InternalAddDataSource(Value:TComponent):Integer;
    Function InternalSetDataSource(Value:TComponent; ClearAll:Boolean):Integer;
    Procedure InternalRemoveDataSource(Value:TComponent);
    Function IsColorStored:Boolean;
    Function IsPercentFormatStored:Boolean;
    Function IsValueFormatStored:Boolean;
    Procedure NotifyColorChanged;
    procedure ReadCustomHorizAxis(Reader: TReader);
    procedure ReadCustomVertAxis(Rea

⌨️ 快捷键说明

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