mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-18 21:59:42 +01:00
TAChart: Extract TCustomChartSource.ValuesInInterval procedure
git-svn-id: trunk@24570 -
This commit is contained in:
parent
b60616fe5a
commit
7f95e20e9c
@ -478,8 +478,7 @@ end;
|
||||
|
||||
procedure TChartAxis.GetMarkValues(AMin, AMax: Double);
|
||||
var
|
||||
i, count: Integer;
|
||||
v: Double;
|
||||
i: Integer;
|
||||
begin
|
||||
AMin := GetTransform.GraphToAxis(AMin);
|
||||
AMax := GetTransform.GraphToAxis(AMax);
|
||||
@ -491,21 +490,9 @@ begin
|
||||
for i := 0 to High(FMarkValues) do
|
||||
FMarkTexts[i] := Format(Marks.Format, [FMarkValues[i]]);
|
||||
end
|
||||
else begin
|
||||
count := 0;
|
||||
SetLength(FMarkValues, Marks.Source.Count);
|
||||
SetLength(FMarkTexts, Marks.Source.Count);
|
||||
for i := 0 to Marks.Source.Count - 1 do begin
|
||||
with Marks.Source[i]^ do
|
||||
v := IfThen(IsVertical, Y, X);
|
||||
if not InRange(v, AMin, AMax) then continue;
|
||||
FMarkValues[count] := v;
|
||||
FMarkTexts[count] := Marks.Source.FormatItem(Marks.Format, i);
|
||||
count += 1;
|
||||
end;
|
||||
SetLength(FMarkValues, count);
|
||||
SetLength(FMarkTexts, count);
|
||||
end;
|
||||
else
|
||||
Marks.Source.ValuesInInterval(
|
||||
AMin, AMax, Marks.Format, IsVertical, FMarkValues, FMarkTexts);
|
||||
|
||||
if Assigned(FOnMarkToText) then
|
||||
for i := 0 to High(FMarkTexts) do
|
||||
|
||||
@ -22,7 +22,7 @@ unit TASources;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Graphics, SysUtils, TAChartUtils;
|
||||
Classes, Graphics, SysUtils, Types, TAChartUtils;
|
||||
|
||||
type
|
||||
EEditableSourceRequired = class(EChartError);
|
||||
@ -61,6 +61,9 @@ type
|
||||
public
|
||||
function Extent: TDoubleRect; virtual;
|
||||
function FormatItem(const AFormat: String; AIndex: Integer): String;
|
||||
procedure ValuesInInterval(
|
||||
AMin, AMax: Double; const AFormat: String; AUseY: Boolean;
|
||||
out AValues: TDoubleDynArray; out ATexts: TStringDynArray);
|
||||
function ValuesTotal: Double; virtual;
|
||||
function XOfMax: Double;
|
||||
function XOfMin: Double;
|
||||
@ -306,6 +309,27 @@ begin
|
||||
FBroadcaster.Broadcast;
|
||||
end;
|
||||
|
||||
procedure TCustomChartSource.ValuesInInterval(
|
||||
AMin, AMax: Double; const AFormat: String; AUseY: Boolean;
|
||||
out AValues: TDoubleDynArray; out ATexts: TStringDynArray);
|
||||
var
|
||||
i, cnt: Integer;
|
||||
v: Double;
|
||||
begin
|
||||
cnt := 0;
|
||||
SetLength(AValues, Count);
|
||||
SetLength(ATexts, Count);
|
||||
for i := 0 to Count - 1 do begin
|
||||
v := IfThen(AUseY, Item[i]^.Y, Item[i]^.X);
|
||||
if not InRange(v, AMin, AMax) then continue;
|
||||
AValues[cnt] := v;
|
||||
ATexts[cnt] := FormatItem(AFormat, i);
|
||||
cnt += 1;
|
||||
end;
|
||||
SetLength(AValues, cnt);
|
||||
SetLength(ATexts, cnt);
|
||||
end;
|
||||
|
||||
function TCustomChartSource.ValuesTotal: Double;
|
||||
var
|
||||
i: Integer;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user