mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 12:56:14 +02:00
TAChart: Replace TChartSeries.GetCoords procedure with GetGraphPoint function
git-svn-id: trunk@21901 -
This commit is contained in:
parent
33343e7d67
commit
c3acc13054
@ -64,7 +64,7 @@ type
|
|||||||
procedure AfterDraw; override;
|
procedure AfterDraw; override;
|
||||||
procedure BeforeDraw; override;
|
procedure BeforeDraw; override;
|
||||||
function ColorOrDefault(AColor: TColor; ADefault: TColor = clTAColor): TColor;
|
function ColorOrDefault(AColor: TColor; ADefault: TColor = clTAColor): TColor;
|
||||||
procedure GetCoords(AIndex: Integer; out AG: TDoublePoint; out AI: TPoint);
|
function GetGraphPoint(AIndex: Integer): TDoublePoint;
|
||||||
function GetXMaxVal: Integer;
|
function GetXMaxVal: Integer;
|
||||||
procedure UpdateBounds(var ABounds: TDoubleRect); override;
|
procedure UpdateBounds(var ABounds: TDoubleRect); override;
|
||||||
public
|
public
|
||||||
@ -278,11 +278,12 @@ begin
|
|||||||
Result := DefaultFormattedMark(AIndex);
|
Result := DefaultFormattedMark(AIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.GetCoords(
|
function TChartSeries.GetGraphPoint(AIndex: Integer): TDoublePoint;
|
||||||
AIndex: Integer; out AG: TDoublePoint; out AI: TPoint);
|
|
||||||
begin
|
begin
|
||||||
AG := DoublePoint(Source[AIndex]^);
|
with Source[AIndex]^ do begin
|
||||||
AI := ParentChart.GraphToImage(AG);
|
Result.X := X;
|
||||||
|
Result.Y := Y;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChartSeries.GetSource: TCustomChartSource;
|
function TChartSeries.GetSource: TCustomChartSource;
|
||||||
|
@ -311,8 +311,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
GraphMath, Math, PropEdits, Types,
|
GraphMath, Math, PropEdits, Types;
|
||||||
TASources;
|
|
||||||
|
|
||||||
{ TLineSeries }
|
{ TLineSeries }
|
||||||
|
|
||||||
@ -372,17 +371,17 @@ begin
|
|||||||
ltNone: ;
|
ltNone: ;
|
||||||
ltFromPrevious:
|
ltFromPrevious:
|
||||||
for i := 0 to Count - 2 do
|
for i := 0 to Count - 2 do
|
||||||
DrawLine(DoublePoint(Source[i]^), DoublePoint(Source[i + 1]^));
|
DrawLine(GetGraphPoint(i), GetGraphPoint(i + 1));
|
||||||
ltFromOrigin:
|
ltFromOrigin:
|
||||||
for i := 0 to Count - 1 do
|
for i := 0 to Count - 1 do
|
||||||
DrawLine(ZeroDoublePoint, DoublePoint(Source[i]^));
|
DrawLine(ZeroDoublePoint, GetGraphPoint(i));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
DrawLabels(ACanvas, true);
|
DrawLabels(ACanvas, true);
|
||||||
|
|
||||||
if FShowPoints then
|
if FShowPoints then
|
||||||
for i := 0 to Count - 1 do begin
|
for i := 0 to Count - 1 do begin
|
||||||
a := DoublePoint(Source[i]^);
|
a := GetGraphPoint(i);
|
||||||
if not ParentChart.IsPointInViewPort(a) then continue;
|
if not ParentChart.IsPointInViewPort(a) then continue;
|
||||||
ai := ParentChart.GraphToImage(a);
|
ai := ParentChart.GraphToImage(a);
|
||||||
FPointer.Draw(ACanvas, ai, GetColor(i));
|
FPointer.Draw(ACanvas, ai, GetColor(i));
|
||||||
@ -670,15 +669,14 @@ end;
|
|||||||
procedure TBasicPointSeries.DrawLabels(ACanvas: TCanvas; ADrawDown: Boolean);
|
procedure TBasicPointSeries.DrawLabels(ACanvas: TCanvas; ADrawDown: Boolean);
|
||||||
var
|
var
|
||||||
g: TDoublePoint;
|
g: TDoublePoint;
|
||||||
pt: TPoint;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if not Marks.IsMarkLabelsVisible then exit;
|
if not Marks.IsMarkLabelsVisible then exit;
|
||||||
for i := 0 to Count - 1 do begin
|
for i := 0 to Count - 1 do begin
|
||||||
GetCoords(i, g, pt);
|
g := GetGraphPoint(i);
|
||||||
with ParentChart do
|
with ParentChart do
|
||||||
if IsPointInViewPort(g) then
|
if IsPointInViewPort(g) then
|
||||||
DrawLabel(ACanvas, i, pt, ADrawDown and (g.Y < 0));
|
DrawLabel(ACanvas, i, GraphToImage(g), ADrawDown and (g.Y < 0));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -792,7 +790,7 @@ begin
|
|||||||
|
|
||||||
ACanvas.Brush.Assign(BarBrush);
|
ACanvas.Brush.Assign(BarBrush);
|
||||||
for i := 0 to Count - 1 do begin
|
for i := 0 to Count - 1 do begin
|
||||||
p := DoublePoint(Source[i]^);
|
p := GetGraphPoint(i);
|
||||||
w := CalcBarWidth(p.X, i);
|
w := CalcBarWidth(p.X, i);
|
||||||
graphBar := DoubleRect(p.X - w, 0, p.X + w, p.Y);
|
graphBar := DoubleRect(p.X - w, 0, p.X + w, p.Y);
|
||||||
if not RectIntersectsRect(graphBar, ext2) then continue;
|
if not RectIntersectsRect(graphBar, ext2) then continue;
|
||||||
@ -812,7 +810,7 @@ begin
|
|||||||
|
|
||||||
if not Marks.IsMarkLabelsVisible then exit;
|
if not Marks.IsMarkLabelsVisible then exit;
|
||||||
for i := 0 to Count - 1 do begin
|
for i := 0 to Count - 1 do begin
|
||||||
p := DoublePoint(Source[i]^);
|
p := GetGraphPoint(i);
|
||||||
if ParentChart.IsPointInViewPort(p) then
|
if ParentChart.IsPointInViewPort(p) then
|
||||||
DrawLabel(ACanvas, i, ParentChart.GraphToImage(p), p.Y < 0);
|
DrawLabel(ACanvas, i, ParentChart.GraphToImage(p), p.Y < 0);
|
||||||
end;
|
end;
|
||||||
@ -1020,8 +1018,8 @@ begin
|
|||||||
ymin := ParentChart.ClipRect.Bottom - 1;
|
ymin := ParentChart.ClipRect.Bottom - 1;
|
||||||
|
|
||||||
for i := 0 to Count - 2 do begin
|
for i := 0 to Count - 2 do begin
|
||||||
a := DoublePoint(Source[i]^);
|
a := GetGraphPoint(i);
|
||||||
b := DoublePoint(Source[i + 1]^);
|
b := GetGraphPoint(i + 1);
|
||||||
if a.X > b.X then begin
|
if a.X > b.X then begin
|
||||||
Exchange(a.X, b.X);
|
Exchange(a.X, b.X);
|
||||||
Exchange(a.Y, b.Y);
|
Exchange(a.Y, b.Y);
|
||||||
|
@ -191,7 +191,6 @@ type
|
|||||||
read FPointsNumber write SetPointsNumber default 0;
|
read FPointsNumber write SetPointsNumber default 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function DoublePoint(const ACoord: TChartDataItem): TDoublePoint; inline; overload;
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
procedure SetDataItemDefaults(var AItem: TChartDataItem);
|
procedure SetDataItemDefaults(var AItem: TChartDataItem);
|
||||||
|
|
||||||
@ -218,12 +217,6 @@ type
|
|||||||
procedure Insert(Index: Integer; const S: string); override;
|
procedure Insert(Index: Integer; const S: string); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function DoublePoint(const ACoord: TChartDataItem): TDoublePoint;
|
|
||||||
begin
|
|
||||||
Result.X := ACoord.X;
|
|
||||||
Result.Y := ACoord.Y;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
RegisterComponents(
|
RegisterComponents(
|
||||||
|
Loading…
Reference in New Issue
Block a user