diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index 255f3897fc..fbf63a4dc5 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -1241,6 +1241,7 @@ begin FYGraphMax := FCurrentExtent.b.Y; exit; end; + Extent.CheckBoundsOrder; // Search # of points, min and max of all series FXGraphMin := Infinity; diff --git a/components/tachart/tatypes.pas b/components/tachart/tatypes.pas index cc8784d214..5f30f1d958 100644 --- a/components/tachart/tatypes.pas +++ b/components/tachart/tatypes.pas @@ -241,6 +241,8 @@ type property Visible default true; end; + EExtentError = class(EChartError); + { TChartExtent } TChartExtent = class (TChartElement) @@ -253,6 +255,7 @@ type procedure SetBounds(AIndex: Integer; const AValue: Double); procedure SetUseBounds(AIndex: Integer; AValue: Boolean); public + procedure CheckBoundsOrder; property Extent: TDoubleRect read FExtent; published property XMin: Double index 1 read GetBounds write SetBounds; @@ -780,6 +783,20 @@ begin Result := FUseBounds[AIndex]; end; +procedure TChartExtent.CheckBoundsOrder; +begin + if UseXMin and UseXMax and (XMin >= XMax) then begin + UseXMin := false; + UseXMax := false; + raise EExtentError.Create('ChartExtent: XMin >= XMax'); + end; + if UseYMin and UseYMax and (YMin >= YMax) then begin + UseYMin := false; + UseYMax := false; + raise EExtentError.Create('ChartExtent: YMin >= YMax'); + end; +end; + function TChartExtent.GetBounds(AIndex: Integer): Double; begin Result := FExtent.coords[AIndex];