TAChart: Fix zooming on auto-scaled series

git-svn-id: trunk@26940 -
This commit is contained in:
ask 2010-07-31 16:55:24 +00:00
parent b95e37f3d3
commit 325d098358
2 changed files with 36 additions and 14 deletions

View File

@ -1046,6 +1046,11 @@ var
begin
Extent.CheckBoundsOrder;
for i := 0 to AxisList.Count - 1 do
with AxisList[i] do
if Transformations <> nil then
Transformations.ClearBounds;
FLogicalExtent := EmptyExtent;
for i := 0 to SeriesCount - 1 do begin
s := Series[i];

View File

@ -47,8 +47,9 @@ type
procedure SetIndex(AValue: Integer); override;
protected
FDrawData: TDrawDataItem;
procedure ClearBounds; virtual;
function GetDrawDataClass: TDrawDataItemClass; virtual;
procedure SetChart(AChart: TObject); virtual;
procedure SetChart(AChart: TObject);
procedure UpdateBounds(var AMin, AMax: Double); virtual;
public
constructor Create(AOwner: TComponent); override;
@ -86,6 +87,7 @@ type
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
public
function AxisToGraph(AX: Double): Double;
procedure ClearBounds;
function GraphToAxis(AX: Double): Double;
procedure SetChart(AChart: TObject);
procedure UpdateBounds(var AMin, AMax: Double);
@ -128,8 +130,8 @@ type
procedure SetMaxValue(const AValue: Double);
procedure SetMinValue(const AValue: Double);
protected
procedure ClearBounds; override;
function GetDrawDataClass: TDrawDataItemClass; override;
procedure SetChart(AChart: TObject); override;
procedure UpdateBounds(var AMin, AMax: Double); override;
public
constructor Create(AOwner: TComponent); override;
@ -326,6 +328,11 @@ begin
Transformations.Broadcaster.Broadcast(Self);
end;
procedure TAxisTransform.ClearBounds;
begin
// empty
end;
constructor TAxisTransform.Create(AOwner: TComponent);
begin
FEnabled := true;
@ -433,6 +440,16 @@ begin
Result := AxisToGraph(Result);
end;
procedure TChartAxisTransformations.ClearBounds;
var
i: Integer;
begin
for i := List.Count - 1 downto 0 do
with TAxisTransform(List[i]) do
if Enabled then
ClearBounds;
end;
constructor TChartAxisTransformations.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@ -610,6 +627,18 @@ begin
Result := AX * FScale + FOffset;
end;
procedure TAutoScaleAxisTransform.ClearBounds;
begin
inherited ClearBounds;
{$R-}{$Q-}
with TAutoScaleTransformData(FDrawData) do begin
FMin := Infinity;
FMax := NegInfinity;
FScale := 1.0;
end;
{$IFDEF OverflowChecking}{$Q+}{$ENDIF}{$IFDEF RangeChecking}{$R+}{$ENDIF}
end;
constructor TAutoScaleAxisTransform.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@ -637,18 +666,6 @@ begin
Result := MinValue <> 0.0;
end;
procedure TAutoScaleAxisTransform.SetChart(AChart: TObject);
begin
inherited SetChart(AChart);
{$R-}{$Q-}
with TAutoScaleTransformData(FDrawData) do begin
FMin := Infinity;
FMax := NegInfinity;
FScale := 1.0;
end;
{$IFDEF OverflowChecking}{$Q+}{$ENDIF}{$IFDEF RangeChecking}{$R+}{$ENDIF}
end;
procedure TAutoScaleAxisTransform.SetMaxValue(const AValue: Double);
begin
if FMaxValue = AValue then exit;