diff --git a/components/tachart/tacustomseries.pas b/components/tachart/tacustomseries.pas index d3ee751c01..74c65b3450 100644 --- a/components/tachart/tacustomseries.pas +++ b/components/tachart/tacustomseries.pas @@ -116,7 +116,6 @@ type function AddXY(X, Y: Double): Integer; overload; inline; procedure Clear; inline; function Count: Integer; inline; - function DefaultFormattedMark(AIndex: integer): String; procedure Delete(AIndex: Integer); virtual; function Extent: TDoubleRect; virtual; function FormattedMark(AIndex: integer): String; @@ -351,22 +350,6 @@ begin FMarks := TChartMarks.Create(FChart); end; -function TChartSeries.DefaultFormattedMark(AIndex: integer): String; -const - TO_PERCENT = 100; -var - total, percent: Double; -begin - total := Source.ValuesTotal; - with Source[AIndex]^ do begin - if total = 0 then - percent := 0 - else - percent := Y / total * TO_PERCENT; - Result := Format(FMarks.Format, [y, percent, Text, total, X]); - end; -end; - procedure TChartSeries.Delete(AIndex: Integer); begin ListSource.Delete(AIndex); @@ -393,7 +376,7 @@ begin if Assigned(FOnGetMark) then FOnGetMark(Result, AIndex) else - Result := DefaultFormattedMark(AIndex); + Result := Source.FormatItem(Marks.Format, AIndex); end; procedure TChartSeries.GetBounds(out ABounds: TDoubleRect); diff --git a/components/tachart/tasources.pas b/components/tachart/tasources.pas index bbfc938a18..3b0edf05b5 100644 --- a/components/tachart/tasources.pas +++ b/components/tachart/tasources.pas @@ -74,6 +74,7 @@ type procedure Unsubscribe(AListener: TListener); public function Extent: TDoubleRect; virtual; + function FormatItem(const AFormat: String; AIndex: Integer): String; function ValuesTotal: Double; virtual; function XOfMax: Double; function XOfMin: Double; @@ -289,6 +290,23 @@ begin Result := -1; end; +function TCustomChartSource.FormatItem( + const AFormat: String; AIndex: Integer): String; +const + TO_PERCENT = 100; +var + total, percent: Double; +begin + total := ValuesTotal; + with Item[AIndex]^ do begin + if total = 0 then + percent := 0 + else + percent := Y / total * TO_PERCENT; + Result := Format(AFormat, [y, percent, Text, total, X]); + end; +end; + procedure TCustomChartSource.InvalidateCaches; begin FExtentIsValid := false;