mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-21 18:20:27 +02:00
TAChart: Use binary search to speed up extent detection for sorted series
+ Fix a typo in TCustomChartSeries.AxisToGraph git-svn-id: trunk@25923 -
This commit is contained in:
parent
a31323c48b
commit
e8d4380072
@ -155,7 +155,7 @@ uses
|
|||||||
function TCustomChartSeries.AxisToGraph(
|
function TCustomChartSeries.AxisToGraph(
|
||||||
const APoint: TDoublePoint): TDoublePoint;
|
const APoint: TDoublePoint): TDoublePoint;
|
||||||
begin
|
begin
|
||||||
Result := DoublePoint(AxisToGraphX(APoint.X), AxisToGraphX(APoint.Y));
|
Result := DoublePoint(AxisToGraphX(APoint.X), AxisToGraphY(APoint.Y));
|
||||||
if IsRotated then
|
if IsRotated then
|
||||||
Exchange(Result.X, Result.Y);
|
Exchange(Result.X, Result.Y);
|
||||||
end;
|
end;
|
||||||
|
@ -309,14 +309,45 @@ end;
|
|||||||
|
|
||||||
procedure TCustomChartSource.FindBounds(
|
procedure TCustomChartSource.FindBounds(
|
||||||
AXMin, AXMax: Double; out ALB, AUB: Integer);
|
AXMin, AXMax: Double; out ALB, AUB: Integer);
|
||||||
|
|
||||||
|
function FindLB(X: Double; L, R: Integer): Integer;
|
||||||
|
begin
|
||||||
|
while L <= R do begin
|
||||||
|
Result := (R - L) div 2 + L;
|
||||||
|
if Item[Result]^.X < X then
|
||||||
|
L := Result + 1
|
||||||
|
else
|
||||||
|
R := Result - 1;
|
||||||
|
end;
|
||||||
|
Result := L;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function FindUB(X: Double; L, R: Integer): Integer;
|
||||||
|
begin
|
||||||
|
while L <= R do begin
|
||||||
|
Result := (R - L) div 2 + L;
|
||||||
|
if Item[Result]^.X <= X then
|
||||||
|
L := Result + 1
|
||||||
|
else
|
||||||
|
R := Result - 1;
|
||||||
|
end;
|
||||||
|
Result := R;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
EnsureOrder(AXMin, AXMax);
|
EnsureOrder(AXMin, AXMax);
|
||||||
ALB := 0;
|
if IsSorted then begin
|
||||||
while (ALB < Count) and (Item[ALB]^.X < AXMin) do
|
ALB := FindLB(AXMin, 0, Count - 1);
|
||||||
Inc(ALB);
|
AUB := FindUB(AXMax, 0, Count - 1);
|
||||||
AUB := Count - 1;
|
end
|
||||||
while (AUB > 0) and (Item[AUB]^.X < AXMax) do
|
else begin
|
||||||
Inc(AUB);
|
ALB := 0;
|
||||||
|
while (ALB < Count) and (Item[ALB]^.X < AXMin) do
|
||||||
|
Inc(ALB);
|
||||||
|
AUB := Count - 1;
|
||||||
|
while (AUB > 0) and (Item[AUB]^.X < AXMax) do
|
||||||
|
Dec(AUB);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomChartSource.FormatItem(
|
function TCustomChartSource.FormatItem(
|
||||||
|
Loading…
Reference in New Issue
Block a user