TAChart: Some more minor improvements of TFuncSeries etc. Patch by Marcin Wiazowski, issue #35200.

git-svn-id: trunk@60618 -
This commit is contained in:
wp 2019-03-07 21:58:08 +00:00
parent 8e58aa9ceb
commit 70c4daf8d1

View File

@ -78,6 +78,7 @@ type
procedure SetOnCalculate(AValue: TFuncCalculateEvent); procedure SetOnCalculate(AValue: TFuncCalculateEvent);
protected protected
function DoCalculate(AX: Double): Double; override; function DoCalculate(AX: Double): Double; override;
procedure GetBounds(var ABounds: TDoubleRect); override;
public public
procedure Assign(ASource: TPersistent); override; procedure Assign(ASource: TPersistent); override;
procedure Draw(ADrawer: IChartDrawer); override; procedure Draw(ADrawer: IChartDrawer); override;
@ -523,8 +524,6 @@ type
procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override; procedure Draw(ADrawer: IChartDrawer; const ARect: TRect); override;
end; end;
TParametricFunc = function (A: Double): TDoublePoint of object;
function ParamsToEquation( function ParamsToEquation(
AEquation: TFitEquation; const AParams: array of Double; AEquation: TFitEquation; const AParams: array of Double;
ANumFormat, AXText, AYText: String): String; ANumFormat, AXText, AYText: String): String;
@ -624,6 +623,7 @@ end;
procedure TCustomFuncSeries.Draw(ADrawer: IChartDrawer); procedure TCustomFuncSeries.Draw(ADrawer: IChartDrawer);
begin begin
if IsEmpty or (not Active) then exit;
ADrawer.SetBrushParams(bsClear, clTAColor); ADrawer.SetBrushParams(bsClear, clTAColor);
ADrawer.Pen := Pen; ADrawer.Pen := Pen;
with TDrawFuncHelper.Create(Self, DomainExclusions, @DoCalculate, Step) do with TDrawFuncHelper.Create(Self, DomainExclusions, @DoCalculate, Step) do
@ -711,15 +711,14 @@ end;
function TFuncSeries.DoCalculate(AX: Double): Double; function TFuncSeries.DoCalculate(AX: Double): Double;
begin begin
OnCalculate(AX, Result) OnCalculate(AX, Result);
end; end;
procedure TFuncSeries.Draw(ADrawer: IChartDrawer); procedure TFuncSeries.Draw(ADrawer: IChartDrawer);
var var
R: TRect; R: TRect;
begin begin
ADrawer.SetBrushParams(bsClear, clTAColor); if not Active then exit;
ADrawer.Pen := Pen;
if csDesigning in ComponentState then begin if csDesigning in ComponentState then begin
with ParentChart do begin with ParentChart do begin
@ -727,19 +726,25 @@ begin
R.BottomRight := GraphToImage(CurrentExtent.b); R.BottomRight := GraphToImage(CurrentExtent.b);
NormalizeRect(R); NormalizeRect(R);
end; end;
ADrawer.SetBrushParams(bsClear, clTAColor);
ADrawer.Pen := Pen;
ADrawer.Line(R.Left, R.Bottom, R.Right, R.Top); ADrawer.Line(R.Left, R.Bottom, R.Right, R.Top);
exit; exit;
end; end;
if IsEmpty then inherited;
exit; end;
with TDrawFuncHelper.Create(Self, DomainExclusions, @DoCalculate, Step) do procedure TFuncSeries.GetBounds(var ABounds: TDoubleRect);
try begin
DrawFunction(ADrawer); inherited GetBounds(ABounds);
finally if not (csDesigning in ComponentState) or
Free; not Extent.UseXMin or not Extent.UseXMax or not ExtentAutoY then exit;
end;
// When designing, an oblique line is drawn (see TFuncSeries.Draw),
// so bounds should be adjusted when ExtentAutoY is True
ABounds.a.Y := ABounds.a.X;
ABounds.b.Y := ABounds.b.X;
end; end;
function TFuncSeries.IsEmpty: Boolean; function TFuncSeries.IsEmpty: Boolean;
@ -803,6 +808,8 @@ var
t, ts, ms: Double; t, ts, ms: Double;
p, pp: TPoint; p, pp: TPoint;
begin begin
if not Active then exit;
ADrawer.SetBrushParams(bsClear, clTAColor); ADrawer.SetBrushParams(bsClear, clTAColor);
ADrawer.Pen := Pen; ADrawer.Pen := Pen;
@ -816,8 +823,7 @@ begin
exit; exit;
end; end;
if IsEmpty then if IsEmpty then exit;
exit;
t := ParamMin; t := ParamMin;
pp := PointAt(ParamMin); pp := PointAt(ParamMin);
@ -2742,10 +2748,10 @@ end;
function TColorMapSeries.FunctionValue(AX, AY: Double): Double; function TColorMapSeries.FunctionValue(AX, AY: Double): Double;
begin begin
if (csDesigning in ComponentState) or not Assigned(FOnCalculate) then if Assigned(OnCalculate) then
Result := 0 OnCalculate(AX, AY, Result)
else else
OnCalculate(AX, AY, Result); Result := 0;
end; end;
function TColorMapSeries.IsEmpty: Boolean; function TColorMapSeries.IsEmpty: Boolean;