TAChart: Extract TBasicPointSeries.GetXRange function

git-svn-id: trunk@27117 -
This commit is contained in:
ask 2010-08-17 09:52:01 +00:00
parent e32deb25d6
commit db61d236a5
2 changed files with 14 additions and 9 deletions

View File

@ -166,6 +166,7 @@ type
procedure DrawLabels(ACanvas: TCanvas);
function GetLabelDirection(AIndex: Integer): TLabelDirection; virtual;
function GetXRange(AX: Double; AIndex: Integer): Double;
procedure PrepareGraphPoints(
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
procedure UpdateMargins(ACanvas: TCanvas; var AMargins: TRect); override;
@ -663,6 +664,18 @@ begin
end;
end;
function TBasicPointSeries.GetXRange(AX: Double; AIndex: Integer): Double;
begin
case CASE_OF_TWO[AIndex > 0, AIndex < Count - 1] of
cotNone: Result := 1.0;
cotFirst: Result := Abs(AX - GetGraphPointX(AIndex - 1));
cotSecond: Result := Abs(AX - GetGraphPointX(AIndex + 1));
cotBoth: Result := Min(
Abs(AX - GetGraphPointX(AIndex - 1)),
Abs(AX - GetGraphPointX(AIndex + 1)));
end;
end;
procedure TBasicPointSeries.MovePoint(
var AIndex: Integer; const ANewPos: TPoint);
var

View File

@ -651,15 +651,7 @@ end;
function TBarSeries.CalcBarWidth(AX: Double; AIndex: Integer): Double;
begin
case CASE_OF_TWO[AIndex > 0, AIndex < Count - 1] of
cotNone: Result := 1.0;
cotFirst: Result := Abs(AX - GetGraphPointX(AIndex - 1));
cotSecond: Result := Abs(AX - GetGraphPointX(AIndex + 1));
cotBoth: Result := Min(
Abs(AX - GetGraphPointX(AIndex - 1)),
Abs(AX - GetGraphPointX(AIndex + 1)));
end;
Result *= FBarWidthPercent * PERCENT / 2;
Result := GetXRange(AX, AIndex) * FBarWidthPercent * PERCENT / 2;
end;
constructor TBarSeries.Create(AOwner: TComponent);