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
i: Integer;
begin
if not Active or (Count = 0) then exit;
if IsEmpty or (not Active) then exit;
with Extent do
for i := Low(coords) to High(coords) do
if not IsInfinite(coords[i]) then
@ -1952,7 +1952,7 @@ var
ysum: Double;
begin
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
changed after the last series' painting). FLoBound and FUpBound will be fully

View File

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

View File

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

View File

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

View File

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

View File

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