TAChart: Rename Auto{X/Y}{Max/Min} to Use{X/Y}{Max/Min} and make it work.

git-svn-id: trunk@19297 -
This commit is contained in:
ask 2009-04-10 08:42:18 +00:00
parent 29df007f71
commit 5c796207d7
4 changed files with 51 additions and 35 deletions

View File

@ -36,6 +36,10 @@ object Form1: TForm1
Extent.YMin = -1 Extent.YMin = -1
Extent.XMax = 6.28 Extent.XMax = 6.28
Extent.YMax = 1 Extent.YMax = 1
Extent.UseXMin = True
Extent.UseYMin = True
Extent.UseXMax = True
Extent.UseYMax = True
Pen.Color = clOlive Pen.Color = clOlive
Pen.Width = 2 Pen.Width = 2
Title = 'Sin(x)' Title = 'Sin(x)'

View File

@ -14,9 +14,10 @@ LazarusResources.Add('TForm1','FORMDATA',[
+'alClient'#5'Color'#7#9'clBtnFace'#11'ParentColor'#8#0#11'TFuncSeries'#17'Ch' +'alClient'#5'Color'#7#9'clBtnFace'#11'ParentColor'#8#0#11'TFuncSeries'#17'Ch'
+'art1FuncSeries1'#11'Extent.XMin'#5#0#248'(\'#143#194#245#200#1#192#11'Exten' +'art1FuncSeries1'#11'Extent.XMin'#5#0#248'(\'#143#194#245#200#1#192#11'Exten'
+'t.YMin'#5#0#0#0#0#0#0#0#128#255#191#11'Extent.XMax'#5#0#248'(\'#143#194#245 +'t.YMin'#5#0#0#0#0#0#0#0#128#255#191#11'Extent.XMax'#5#0#248'(\'#143#194#245
+#200#1'@'#11'Extent.YMax'#5#0#0#0#0#0#0#0#128#255'?'#9'Pen.Color'#7#7'clOliv' +#200#1'@'#11'Extent.YMax'#5#0#0#0#0#0#0#0#128#255'?'#14'Extent.UseXMin'#9#14
+'e'#9'Pen.Width'#2#2#5'Title'#6#6'Sin(x)'#0#0#5'TLine'#11'Chart1XAxis'#12'Sh' +'Extent.UseYMin'#9#14'Extent.UseXMax'#9#14'Extent.UseYMax'#9#9'Pen.Color'#7#7
+'owInLegend'#8#11'SeriesColor'#7#7'clBlack'#0#0#5'TLine'#11'Chart1YAxis'#12 +'clOlive'#9'Pen.Width'#2#2#5'Title'#6#6'Sin(x)'#0#0#5'TLine'#11'Chart1XAxis'
+'ShowInLegend'#8#9'LineStyle'#7#10'lsVertical'#11'SeriesColor'#7#7'clBlack'#0 +#12'ShowInLegend'#8#11'SeriesColor'#7#7'clBlack'#0#0#5'TLine'#11'Chart1YAxis'
+#0#0#0 +#12'ShowInLegend'#8#9'LineStyle'#7#10'lsVertical'#11'SeriesColor'#7#7'clBlac'
+'k'#0#0#0#0
]); ]);

View File

@ -1555,19 +1555,28 @@ procedure TFuncSeries.Draw(ACanvas: TCanvas);
begin begin
FChart.XImageToGraph(AX, xg); FChart.XImageToGraph(AX, xg);
OnCalculate(xg, yg); OnCalculate(xg, yg);
yg := EnsureRange(yg, Extent.YMin, Extent.YMax); if Extent.UseYMin and (yg < Extent.YMin) then
yg := Extent.YMin;
if Extent.UseYMax and (yg > Extent.YMax) then
yg := Extent.YMax;
FChart.YGraphToImage(yg, Result); FChart.YGraphToImage(yg, Result);
end; end;
var var
x, xmax: Integer; x, xmax, t: Integer;
begin begin
if not Assigned(OnCalculate) then exit; if not Assigned(OnCalculate) then exit;
FChart.XGraphToImage(Extent.XMin, x); x := FChart.ClipRect.Left;
x := Max(x, FChart.ClipRect.Left); if Extent.UseXMin then begin
FChart.XGraphToImage(Extent.XMax, xmax); FChart.XGraphToImage(Extent.XMin, t);
xmax := Min(xmax, FChart.ClipRect.Right); x := Max(x, t);
end;
xmax := FChart.ClipRect.Right;
if Extent.UseXMax then begin
FChart.XGraphToImage(Extent.XMax, t);
x := Min(x, t);
end;
ACanvas.Pen.Assign(Pen); ACanvas.Pen.Assign(Pen);
@ -1657,10 +1666,12 @@ end;
procedure TFuncSeries.UpdateBounds(var AXMin, AYMin, AXMax, AYMax: Double); procedure TFuncSeries.UpdateBounds(var AXMin, AYMin, AXMax, AYMax: Double);
begin begin
if Extent.XMin < AXMin then AXMin := Extent.XMin; with Extent do begin
if Extent.YMin < AYMin then AYMin := Extent.YMin; if UseXMin and (XMin < AXMin) then AXMin := XMin;
if Extent.XMax > AXMax then AXMax := Extent.XMax; if UseYMin and (YMin < AYMin) then AYMin := YMin;
if Extent.YMax > AYMax then AYMax := Extent.YMax; if UseXMax and (XMax > AXMax) then AXMax := XMax;
if UseYMax and (YMax > AYMax) then AYMax := YMax;
end;
end; end;
procedure TFuncSeries.UpdateParentChart; procedure TFuncSeries.UpdateParentChart;

View File

@ -243,23 +243,23 @@ type
TChartExtent = class (TChartElement) TChartExtent = class (TChartElement)
private private
FExtent: TDoubleRect; FExtent: TDoubleRect;
FAuto: array [1..4] of Boolean; FUseBounds: array [1..4] of Boolean;
function GetAuto(AIndex: integer): Boolean; function GetBounds(AIndex: Integer): Double;
function GetBorder(AIndex: Integer): Double; function GetUseBounds(AIndex: integer): Boolean;
procedure SetAuto(AIndex: Integer; AValue: Boolean); procedure SetBounds(AIndex: Integer; const AValue: Double);
procedure SetBorder(AIndex: Integer; const AValue: Double); procedure SetUseBounds(AIndex: Integer; AValue: Boolean);
public public
property Extent: TDoubleRect read FExtent; property Extent: TDoubleRect read FExtent;
published published
property XMin: Double index 1 read GetBorder write SetBorder; property XMin: Double index 1 read GetBounds write SetBounds;
property YMin: Double index 2 read GetBorder write SetBorder; property YMin: Double index 2 read GetBounds write SetBounds;
property XMax: Double index 3 read GetBorder write SetBorder; property XMax: Double index 3 read GetBounds write SetBounds;
property YMax: Double index 4 read GetBorder write SetBorder; property YMax: Double index 4 read GetBounds write SetBounds;
property AutoXMin: Boolean index 1 read GetAuto write SetAuto; property UseXMin: Boolean index 1 read GetUseBounds write SetUseBounds;
property AutoYMin: Boolean index 2 read GetAuto write SetAuto; property UseYMin: Boolean index 2 read GetUseBounds write SetUseBounds;
property AutoXMax: Boolean index 3 read GetAuto write SetAuto; property UseXMax: Boolean index 3 read GetUseBounds write SetUseBounds;
property AutoYMax: Boolean index 4 read GetAuto write SetAuto; property UseYMax: Boolean index 4 read GetUseBounds write SetUseBounds;
end; end;
const const
@ -770,23 +770,23 @@ end;
{ TChartExtent } { TChartExtent }
function TChartExtent.GetAuto(AIndex: Integer): Boolean; function TChartExtent.GetUseBounds(AIndex: Integer): Boolean;
begin begin
Result := FAuto[AIndex]; Result := FUseBounds[AIndex];
end; end;
function TChartExtent.GetBorder(AIndex: Integer): Double; function TChartExtent.GetBounds(AIndex: Integer): Double;
begin begin
Result := Extent.coords[AIndex]; Result := FExtent.coords[AIndex];
end; end;
procedure TChartExtent.SetAuto(AIndex: Integer; AValue: Boolean); procedure TChartExtent.SetUseBounds(AIndex: Integer; AValue: Boolean);
begin begin
FAuto[AIndex] := AValue; FUseBounds[AIndex] := AValue;
StyleChanged(Self); StyleChanged(Self);
end; end;
procedure TChartExtent.SetBorder(AIndex: Integer; const AValue: Double); procedure TChartExtent.SetBounds(AIndex: Integer; const AValue: Double);
begin begin
FExtent.coords[AIndex] := AValue; FExtent.coords[AIndex] := AValue;
StyleChanged(Self); StyleChanged(Self);