mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 22:30:39 +02:00
TAChart: Move TCustomChartSeries.DefaultFormattedMark to TCustomChartSource.FormatItem
git-svn-id: trunk@24141 -
This commit is contained in:
parent
bb59f395e3
commit
85eb77d20d
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user