TAChart: Use TChartAxis.Range even if no series is assigned to the axis

git-svn-id: trunk@32028 -
This commit is contained in:
ask 2011-08-21 10:40:49 +00:00
parent b001e5e50e
commit 74bfc779a0
2 changed files with 35 additions and 14 deletions

View File

@ -113,7 +113,6 @@ type
FZPosition: TChartDistance;
function GetMarks: TChartAxisMarks; inline;
function GetTransform: TChartAxisTransformations;
procedure SetAxisPen(AValue: TChartAxisPen);
procedure SetGroup(AValue: Integer);
procedure SetInverted(AValue: Boolean);
@ -139,12 +138,14 @@ type
procedure Draw;
procedure DrawTitle(const ACenter: TPoint; ASize: Integer);
function GetChart: TCustomChart; inline;
function GetTransform: TChartAxisTransformations;
function IsVertical: Boolean; inline;
procedure Measure(
const AExtent: TDoubleRect; var AMeasureData: TChartAxisGroup);
procedure PrepareHelper(
ADrawer: IChartDrawer; const ATransf: ICoordTransformer;
AClipRect: PRect; AMaxZPosition: Integer);
procedure UpdateBounds(var AMin, AMax: Double);
published
property Alignment default calLeft;
property Arrow;
@ -287,12 +288,7 @@ procedure UpdateBoundsByAxisRange(
AAxisList: TChartAxisList; AIndex: Integer; var AMin, AMax: Double);
begin
if not InRange(AIndex, 0, AAxisList.Count - 1) then exit;
with AAxisList[AIndex].Range do begin
if UseMin then
AMin := Min;
if UseMax then
AMax := Max;
end;
AAxisList[AIndex].UpdateBounds(AMin, AMax);
end;
{ TChartAxisEnumerator }
@ -794,6 +790,16 @@ begin
end;
end;
procedure TChartAxis.UpdateBounds(var AMin, AMax: Double);
begin
with Range do begin
if UseMin then
AMin := Min;
if UseMax then
AMax := Max;
end;
end;
procedure TChartAxis.VisitSource(ASource: TCustomChartSource; var AData);
var
ext: TDoubleRect;

View File

@ -917,8 +917,18 @@ function TChart.GetFullExtent: TDoubleRect;
end;
end;
procedure JoinBounds(const ABounds: TDoubleRect);
begin
with Result do begin
a.X := Min(a.X, ABounds.a.X);
b.X := Max(b.X, ABounds.b.X);
a.Y := Min(a.Y, ABounds.a.Y);
b.Y := Max(b.Y, ABounds.b.Y);
end;
end;
var
seriesBounds: TDoubleRect;
seriesBounds, axisBounds: TDoubleRect;
s: TBasicChartSeries;
a: TChartAxis;
begin
@ -938,12 +948,17 @@ begin
s.Active := false;
raise;
end;
with Result do begin
a.X := Min(a.X, seriesBounds.a.X);
b.X := Max(b.X, seriesBounds.b.X);
a.Y := Min(a.Y, seriesBounds.a.Y);
b.Y := Max(b.Y, seriesBounds.b.Y);
end;
JoinBounds(seriesBounds);
end;
for a in AxisList do begin
axisBounds := EmptyExtent;
if a.Range.UseMin then
TDoublePointBoolArr(axisBounds.a)[a.IsVertical] :=
a.GetTransform.AxisToGraph(a.Range.Min);
if a.Range.UseMax then
TDoublePointBoolArr(axisBounds.b)[a.IsVertical] :=
a.GetTransform.AxisToGraph(a.Range.Max);
JoinBounds(axisBounds);
end;
with Extent do begin
SetBounds(Result.a.X, Result.b.X, XMin, XMax, UseXMin, UseXMax);