mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-27 02:33:38 +02:00
TAChart: Display fit equation as default title for TFitSeries
git-svn-id: trunk@32935 -
This commit is contained in:
parent
4447f89ee8
commit
ca2895871a
components/tachart
@ -77,6 +77,7 @@ type
|
||||
strict protected
|
||||
function GetIndex: Integer; override;
|
||||
procedure SetIndex(AValue: Integer); override;
|
||||
function TitleIsStored: Boolean; virtual;
|
||||
|
||||
public
|
||||
function AxisToGraph(const APoint: TDoublePoint): TDoublePoint;
|
||||
@ -104,7 +105,7 @@ type
|
||||
read FAxisIndexX write SetAxisIndexX default DEF_AXIS_INDEX;
|
||||
property AxisIndexY: Integer
|
||||
read FAxisIndexY write SetAxisIndexY default DEF_AXIS_INDEX;
|
||||
property Title: String read FTitle write SetTitle;
|
||||
property Title: String read FTitle write SetTitle stored TitleIsStored;
|
||||
|
||||
published
|
||||
property Legend: TChartSeriesLegend read FLegend write SetLegend;
|
||||
@ -501,6 +502,11 @@ begin
|
||||
ParentChart.StyleChanged(Sender);
|
||||
end;
|
||||
|
||||
function TCustomChartSeries.TitleIsStored: Boolean;
|
||||
begin
|
||||
Result := Title <> '';
|
||||
end;
|
||||
|
||||
procedure TCustomChartSeries.UpdateParentChart;
|
||||
begin
|
||||
if ParentChart <> nil then
|
||||
|
@ -32,6 +32,7 @@ const
|
||||
DEF_SPLINE_STEP = 4;
|
||||
DEF_FIT_STEP = 4;
|
||||
DEF_FIT_PARAM_COUNT = 3;
|
||||
DEF_FIT_TITLE = '%s';
|
||||
DEF_COLORMAP_STEP = 4;
|
||||
|
||||
type
|
||||
@ -231,6 +232,7 @@ type
|
||||
strict protected
|
||||
procedure CalcXRange(out AXMin, AXMax: Double);
|
||||
procedure Transform(AX, AY: Double; out ANewX, ANewY: Extended);
|
||||
function TitleIsStored: Boolean; override;
|
||||
protected
|
||||
procedure AfterAdd; override;
|
||||
procedure GetLegendItems(AItems: TChartLegendItems); override;
|
||||
@ -1128,6 +1130,7 @@ begin
|
||||
FPen := TChartPen.Create;
|
||||
FPen.OnChange := @StyleChanged;
|
||||
FStep := DEF_FIT_STEP;
|
||||
Title := DEF_FIT_TITLE;
|
||||
ParamCount := DEF_FIT_PARAM_COUNT; // Parabolic fit as default.
|
||||
end;
|
||||
|
||||
@ -1219,8 +1222,13 @@ begin
|
||||
end;
|
||||
|
||||
procedure TFitSeries.GetLegendItems(AItems: TChartLegendItems);
|
||||
var
|
||||
t: String;
|
||||
begin
|
||||
AItems.Add(TLegendItemLine.Create(Pen, Title));
|
||||
t := Title;
|
||||
if Pos(DEF_FIT_TITLE, t) > 0 then
|
||||
t := Format(t, [GetFitEquationString('%f')]);
|
||||
AItems.Add(TLegendItemLine.Create(Pen, t));
|
||||
end;
|
||||
|
||||
function TFitSeries.GetNearestPoint(
|
||||
@ -1330,6 +1338,11 @@ begin
|
||||
ExecFit;
|
||||
end;
|
||||
|
||||
function TFitSeries.TitleIsStored: Boolean;
|
||||
begin
|
||||
Result := Title <> DEF_FIT_TITLE;
|
||||
end;
|
||||
|
||||
procedure TFitSeries.Transform(AX, AY: Double; out ANewX, ANewY: Extended);
|
||||
begin
|
||||
// The exponential and power fitting equations can be transformed to a
|
||||
|
Loading…
Reference in New Issue
Block a user