TAChart: Exit public series methods when series is empty. Issue #35618, patch by Marcin Wiazowski.

git-svn-id: trunk@61268 -
This commit is contained in:
wp 2019-05-22 09:32:35 +00:00
parent 592a9daf42
commit 95ca9460ab
6 changed files with 25 additions and 20 deletions

View File

@ -890,7 +890,7 @@ procedure TChartSeries.GetBounds(var ABounds: TDoubleRect);
var var
i: Integer; i: Integer;
begin begin
if not Active or (Count = 0) then exit; if IsEmpty or (not Active) then exit;
with Extent do with Extent do
for i := Low(coords) to High(coords) do for i := Low(coords) to High(coords) do
if not IsInfinite(coords[i]) then if not IsInfinite(coords[i]) then
@ -1952,7 +1952,7 @@ var
ysum: Double; ysum: Double;
begin begin
if not Marks.IsMarkLabelsVisible or not Marks.AutoMargins then exit; if not Marks.IsMarkLabelsVisible or not Marks.AutoMargins then exit;
if Count = 0 then exit; if IsEmpty then exit;
{FLoBound and FUpBound fields may be outdated here (if axis' range has been {FLoBound and FUpBound fields may be outdated here (if axis' range has been
changed after the last series' painting). FLoBound and FUpBound will be fully changed after the last series' painting). FLoBound and FUpBound will be fully

View File

@ -537,6 +537,7 @@ end;
procedure TExpressionSeries.Draw(ADrawer: IChartDrawer); procedure TExpressionSeries.Draw(ADrawer: IChartDrawer);
begin begin
if (not Active) then exit;
SetupParser; SetupParser;
inherited; inherited;
end; end;
@ -672,6 +673,7 @@ end;
procedure TExpressionColorMapSeries.Draw(ADrawer: IChartDrawer); procedure TExpressionColorMapSeries.Draw(ADrawer: IChartDrawer);
begin begin
if (not Active) then exit;
SetupParser; SetupParser;
inherited; inherited;
end; end;

View File

@ -1,4 +1,4 @@
{ {
Function series for TAChart. Function series for TAChart.
@ -729,7 +729,7 @@ procedure TFuncSeries.Draw(ADrawer: IChartDrawer);
var var
R: TRect; R: TRect;
begin begin
if not Active then exit; if (not Active) then exit;
if csDesigning in ComponentState then begin if csDesigning in ComponentState then begin
with ParentChart do begin with ParentChart do begin
@ -819,7 +819,7 @@ var
t, ts, ms: Double; t, ts, ms: Double;
p, pp: TPoint; p, pp: TPoint;
begin begin
if not Active then exit; if (not Active) then exit;
ADrawer.SetBrushParams(bsClear, clTAColor); ADrawer.SetBrushParams(bsClear, clTAColor);
ADrawer.Pen := Pen; ADrawer.Pen := Pen;
@ -1121,7 +1121,7 @@ var
var var
i: Integer; i: Integer;
begin begin
if IsEmpty then exit; if IsEmpty or (not Active) then exit;
SetLength(p, Degree + 1); SetLength(p, Degree + 1);
@ -2425,7 +2425,7 @@ begin
if FPaletteMin < FPaletteMax then begin if FPaletteMin < FPaletteMax then begin
cmin := FPaletteMin; cmin := FPaletteMin;
cmax := FPaletteMax; cmax := FPaletteMax;
end else end else
if FPaletteMax < FPaletteMin then begin if FPaletteMax < FPaletteMin then begin
cmin := FPaletteMax; cmin := FPaletteMax;
cmax := FPaletteMin; cmax := FPaletteMin;
@ -2512,7 +2512,7 @@ var
scaled_stepX: Integer; scaled_stepX: Integer;
scaled_stepY: Integer; scaled_stepY: Integer;
begin begin
if not (csDesigning in ComponentState) and IsEmpty then exit; if (not (csDesigning in ComponentState) and IsEmpty) or (not Active) then exit;
ext := ParentChart.CurrentExtent; ext := ParentChart.CurrentExtent;
bounds := EmptyExtent; bounds := EmptyExtent;

View File

@ -516,7 +516,7 @@ var
ext: TDoubleRect; ext: TDoubleRect;
nx, ny: Cardinal; nx, ny: Cardinal;
begin begin
if IsEmpty then exit; if IsEmpty or (not Active) then exit;
if not RequestValidChartScaling then exit; if not RequestValidChartScaling then exit;
ADrawer.Pen := BubblePen; ADrawer.Pen := BubblePen;
@ -876,7 +876,7 @@ var
center: Double; center: Double;
begin begin
if not Marks.IsMarkLabelsVisible or not Marks.AutoMargins then exit; if not Marks.IsMarkLabelsVisible or not Marks.AutoMargins then exit;
if Count = 0 then exit; if IsEmpty then exit;
if not RequestValidChartScaling then exit; if not RequestValidChartScaling then exit;
FindExtentInterval(ParentChart.CurrentExtent, Source.IsSortedByXAsc); FindExtentInterval(ParentChart.CurrentExtent, Source.IsSortedByXAsc);
@ -984,8 +984,8 @@ var
i: Integer; i: Integer;
nx, ny: Cardinal; nx, ny: Cardinal;
begin begin
if IsEmpty then if IsEmpty or (not Active) then exit;
exit;
if FWidthStyle = bwsPercentMin then if FWidthStyle = bwsPercentMin then
UpdateMinXRange; UpdateMinXRange;
@ -1432,8 +1432,9 @@ var
p: TPen; p: TPen;
nx, ny: Cardinal; nx, ny: Cardinal;
begin begin
if IsEmpty or (not Active) then exit;
my := MaxIntValue([YIndexOpen, YIndexHigh, YIndexLow, YIndexClose]); my := MaxIntValue([YIndexOpen, YIndexHigh, YIndexLow, YIndexClose]);
if IsEmpty or (my >= Source.YCount) then exit; if my >= Source.YCount then exit;
ext2 := ParentChart.CurrentExtent; ext2 := ParentChart.CurrentExtent;
ExpandRange(ext2.a.X, ext2.b.X, 1.0); ExpandRange(ext2.a.X, ext2.b.X, 1.0);
@ -1807,6 +1808,7 @@ var
p1, p2: TDoublePoint; p1, p2: TDoublePoint;
lPen: TPen; lPen: TPen;
begin begin
if IsEmpty or (not Active) then exit;
with Extent do begin with Extent do begin
ext.a := AxisToGraph(a); ext.a := AxisToGraph(a);
ext.b := AxisToGraph(b); ext.b := AxisToGraph(b);

View File

@ -627,7 +627,7 @@ var
prevLabelPoly: TPointArray = nil; prevLabelPoly: TPointArray = nil;
ps: TPieSlice; ps: TPieSlice;
begin begin
if IsEmpty then exit; if IsEmpty or (not Active) then exit;
Marks.SetAdditionalAngle(0); Marks.SetAdditionalAngle(0);
Measure(ADrawer); Measure(ADrawer);
@ -1263,8 +1263,7 @@ var
var var
j: Integer; j: Integer;
begin begin
if IsEmpty then exit; if IsEmpty or (not Active) then exit;
originPt := ParentChart.GraphToImage(DoublePoint(OriginX, OriginY)); originPt := ParentChart.GraphToImage(DoublePoint(OriginX, OriginY));
fill := FFilled and (FBrush.Style <> bsClear); fill := FFilled and (FBrush.Style <> bsClear);
SetLength(pts, Count + 1); // +1 for origin SetLength(pts, Count + 1); // +1 for origin

View File

@ -469,8 +469,7 @@ var
ext: TDoubleRect; ext: TDoubleRect;
i: Integer; i: Integer;
begin begin
if IsEmpty then exit; if IsEmpty or (not Active) then exit;
with Extent do begin with Extent do begin
ext.a := AxisToGraph(a); ext.a := AxisToGraph(a);
ext.b := AxisToGraph(b); ext.b := AxisToGraph(b);
@ -855,6 +854,7 @@ var
end; end;
begin begin
if IsEmpty or (not Active) then exit;
with Extent do begin with Extent do begin
ext.a := AxisToGraph(a); ext.a := AxisToGraph(a);
ext.b := AxisToGraph(b); ext.b := AxisToGraph(b);
@ -946,6 +946,7 @@ procedure TConstantLine.Draw(ADrawer: IChartDrawer);
var var
p: Integer; p: Integer;
begin begin
if IsEmpty or (not Active) then exit;
if Pen.Style = psClear then exit; if Pen.Style = psClear then exit;
ADrawer.SetBrushParams(bsClear, clTAColor); ADrawer.SetBrushParams(bsClear, clTAColor);
@ -1227,7 +1228,7 @@ var
ofs, y: Double; ofs, y: Double;
zero: Double; zero: Double;
begin begin
if IsEmpty then exit; if IsEmpty or (not Active) then exit;
if BarWidthStyle = bwPercentMin then if BarWidthStyle = bwPercentMin then
UpdateMinXRange; UpdateMinXRange;
@ -2132,7 +2133,7 @@ var
var var
j, k: Integer; j, k: Integer;
begin begin
if IsEmpty then exit; if IsEmpty or (not Active) then exit;
ext := ParentChart.CurrentExtent; ext := ParentChart.CurrentExtent;
ext2 := ext; ext2 := ext;
@ -2280,6 +2281,7 @@ procedure TUserDrawnSeries.Draw(ADrawer: IChartDrawer);
var var
ic: IChartTCanvasDrawer; ic: IChartTCanvasDrawer;
begin begin
if IsEmpty or (not Active) then exit;
if Supports(ADrawer, IChartTCanvasDrawer, ic) and Assigned(FOnDraw) then if Supports(ADrawer, IChartTCanvasDrawer, ic) and Assigned(FOnDraw) then
FOnDraw(ic.Canvas, FChart.ClipRect); FOnDraw(ic.Canvas, FChart.ClipRect);
end; end;