{**********************************************}
{   TDonutSeries                               }
{   A Pie Series with a hole in the center.    }
{                                              }
{   Copyright (c) 1999-2020 by Steema Software }
{**********************************************}
unit TeeDonut;
{$I TeeDefs.inc}

interface

Uses {$IFNDEF LINUX}
     {$IFNDEF FMX}
     Windows,
     {$ENDIF}
     {$ENDIF}
     SysUtils, Classes,
     {$IFDEF FMX}
     FMX.Types,
     {$ELSE}
     Graphics,
     {$ENDIF}

     {$IFDEF FMX}
     FMXTee.Engine, FMXTee.Chart, FMXTee.Canvas, FMXTee.Series
     {$ELSE}
     TeEngine, Chart, TeCanvas, Series
     {$ENDIF};

const
  TeeDefaultDonutPercent = 50;

type
  TDonutSeries=class(TPieSeries)
  protected
    procedure AssignFormatting(Source: TChartSeries); override;
    class Function GetEditorClass:String; override;
  public
    Constructor Create(AOwner: TComponent); override;
  published
    property DonutPercent default TeeDefaultDonutPercent;
  end;

implementation

Uses
  {$IFDEF FMX}
  FMXTee.Constants, FMXTee.ProConstants
  {$ELSE}
  TeeConst, TeeProCo
  {$ENDIF};

{ TDonutSeries }
Constructor TDonutSeries.Create(AOwner: TComponent);
begin
  inherited;
  SetDonutPercent(TeeDefaultDonutPercent);
end;

procedure TDonutSeries.AssignFormatting(Source: TChartSeries);
begin
  if Source is TDonutSeries then
  With TDonutSeries(Source) do
  begin
    Self.DonutPercent:=DonutPercent;
  end;

  inherited;

  if DonutPercent<=0 then
     SetDonutPercent(TeeDefaultDonutPercent);
end;

class Function TDonutSeries.GetEditorClass:String;
begin
  result:='TDonutSeriesEditor'; // Do not localize
end;

initialization
  RegisterTeeSeries(TDonutSeries, @TeeMsg_GalleryDonut,
                                  @TeeMsg_GalleryExtended,1);
finalization
  UnRegisterTeeSeries([TDonutSeries]);
end.
