mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 06:09:15 +02:00
TAChart: Avoid double call to SetLength from ValuesInRange for unsorted TCustomChartSource
git-svn-id: trunk@38659 -
This commit is contained in:
parent
5fc1caeffa
commit
14c82d694e
@ -776,8 +776,23 @@ var
|
|||||||
prevImagePos := imagePos;
|
prevImagePos := imagePos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function EnsureMinLength(AStart, AEnd: Integer): Integer;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
v: Double;
|
||||||
|
begin
|
||||||
|
prevImagePos := MaxInt;
|
||||||
|
Result := AStart;
|
||||||
|
for i := AStart to AEnd do begin
|
||||||
|
v := AValues[i].FValue;
|
||||||
|
if InRange(v, AParams.FMin, AParams.FMax) and IsTooClose(v) then continue;
|
||||||
|
AValues[Result] := AValues[i];
|
||||||
|
Result += 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
i, j, cnt, start: Integer;
|
i, cnt, start: Integer;
|
||||||
v: Double;
|
v: Double;
|
||||||
lo, hi: TChartValueText;
|
lo, hi: TChartValueText;
|
||||||
begin
|
begin
|
||||||
@ -827,21 +842,13 @@ begin
|
|||||||
AValues[cnt] := hi;
|
AValues[cnt] := hi;
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
end;
|
end;
|
||||||
SetLength(AValues, cnt);
|
|
||||||
|
|
||||||
if IsSorted or IsValueTextsSorted(AValues, start, cnt - 1) then exit;
|
if not IsSorted and not IsValueTextsSorted(AValues, start, cnt - 1) then begin
|
||||||
SortValuesInRange(AValues, start, cnt - 1);
|
SortValuesInRange(AValues, start, cnt - 1);
|
||||||
if aipUseMinLength in AParams.FIntervals.Options then begin
|
if aipUseMinLength in AParams.FIntervals.Options then
|
||||||
prevImagePos := MaxInt;
|
cnt := EnsureMinLength(start, cnt - 1);
|
||||||
j := start;
|
|
||||||
for i := start to cnt - 1 do begin
|
|
||||||
v := AValues[i].FValue;
|
|
||||||
if InRange(v, AParams.FMin, AParams.FMax) and IsTooClose(v) then continue;
|
|
||||||
AValues[j] := AValues[i];
|
|
||||||
j += 1;
|
|
||||||
end;
|
|
||||||
SetLength(AValues, j);
|
|
||||||
end;
|
end;
|
||||||
|
SetLength(AValues, cnt);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomChartSource.ValuesTotal: Double;
|
function TCustomChartSource.ValuesTotal: Double;
|
||||||
|
Loading…
Reference in New Issue
Block a user