mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 02:16:09 +02:00
TAChart: Add ready-made procedure to call DataPoints editor from user call. Add option to hide Color column.
git-svn-id: trunk@60514 -
This commit is contained in:
parent
62321271bf
commit
fdf2e848f4
@ -34,23 +34,9 @@ end;
|
|||||||
{ TDataPointsPropertyEditor }
|
{ TDataPointsPropertyEditor }
|
||||||
|
|
||||||
procedure TDataPointsPropertyEditor.Edit;
|
procedure TDataPointsPropertyEditor.Edit;
|
||||||
var
|
|
||||||
dataModified: Boolean;
|
|
||||||
begin
|
begin
|
||||||
with TDataPointsEditorForm.Create(nil) do
|
if DataPointsEditor(GetComponent(0) as TListChartSource) then
|
||||||
try
|
Modified;
|
||||||
InitData(
|
|
||||||
(GetComponent(0) as TListChartsource).XCount,
|
|
||||||
(GetComponent(0) as TListChartSource).YCount,
|
|
||||||
GetObjectValue as TStrings
|
|
||||||
);
|
|
||||||
if ShowModal = mrOK then begin
|
|
||||||
ExtractData(dataModified);
|
|
||||||
if dataModified then Modified;
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
Free;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDataPointsPropertyEditor.GetAttributes: TPropertyAttributes;
|
function TDataPointsPropertyEditor.GetAttributes: TPropertyAttributes;
|
||||||
|
@ -15,10 +15,13 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
ButtonPanel, Classes, ExtCtrls, Grids, Menus, SysUtils, Forms, Controls,
|
ButtonPanel, Classes, ExtCtrls, Grids, Menus, SysUtils, Forms, Controls,
|
||||||
Graphics, Dialogs;
|
Graphics, Dialogs, TASources;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
TDataPointsEditorOption = (dpeHideColorColumn);
|
||||||
|
TDataPointsEditorOptions = set of TDataPointsEditorOption;
|
||||||
|
|
||||||
{ TDataPointsEditorForm }
|
{ TDataPointsEditorForm }
|
||||||
|
|
||||||
TDataPointsEditorForm = class(TForm)
|
TDataPointsEditorForm = class(TForm)
|
||||||
@ -49,21 +52,49 @@ type
|
|||||||
FDataPoints: TStrings;
|
FDataPoints: TStrings;
|
||||||
FXCount: Integer;
|
FXCount: Integer;
|
||||||
FYCount: Integer;
|
FYCount: Integer;
|
||||||
|
FOptions: TDataPointsEditorOptions;
|
||||||
procedure UpdateCmds;
|
procedure UpdateCmds;
|
||||||
function ValidData(out ACol, ARow: Integer; out AMsg: String): Boolean;
|
function ValidData(out ACol, ARow: Integer; out AMsg: String): Boolean;
|
||||||
public
|
public
|
||||||
procedure InitData(AXCount, AYCount: Integer; ADataPoints: TStrings);
|
procedure InitData(AXCount, AYCount: Integer; ADataPoints: TStrings;
|
||||||
|
AOptions: TDataPointsEditorOptions = []);
|
||||||
procedure ExtractData(out AModified: Boolean);
|
procedure ExtractData(out AModified: Boolean);
|
||||||
|
property Options: TDatapointsEditorOptions read FOptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function DataPointsEditor(AListChartSource: TListChartsource;
|
||||||
|
AOptions: TDataPointsEditorOptions = []): Boolean;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LCLIntf, LCLType, Math, StdCtrls,
|
LCLIntf, LCLType, Math, StdCtrls,
|
||||||
TAChartStrConsts, TAChartUtils, TASources;
|
TAChartStrConsts, TAChartUtils;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
|
function DataPointsEditor(AListChartSource: TListChartsource;
|
||||||
|
AOptions: TDataPointsEditorOptions = []): Boolean;
|
||||||
|
var
|
||||||
|
F: TDataPointsEditorForm;
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
F := TDataPointsEditorForm.Create(Application);
|
||||||
|
try
|
||||||
|
F.InitData(
|
||||||
|
AListChartSource.XCount,
|
||||||
|
AListChartSource.YCount,
|
||||||
|
AListChartSource.DataPoints,
|
||||||
|
AOptions
|
||||||
|
);
|
||||||
|
if F.ShowModal = mrOK then
|
||||||
|
F.ExtractData(Result);
|
||||||
|
finally
|
||||||
|
F.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function EditText(var AText: String): Boolean;
|
function EditText(var AText: String): Boolean;
|
||||||
var
|
var
|
||||||
F: TForm;
|
F: TForm;
|
||||||
@ -121,8 +152,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDataPointsEditorForm.InitData(
|
procedure TDataPointsEditorForm.InitData(AXCount, AYCount: Integer;
|
||||||
AXCount, AYCount: Integer; ADataPoints: TStrings);
|
ADataPoints: TStrings; AOptions: TDataPointsEditorOptions = []);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
w: Integer;
|
w: Integer;
|
||||||
@ -130,6 +161,7 @@ begin
|
|||||||
FXCount := AXCount;
|
FXCount := AXCount;
|
||||||
FYCount := AYCount;
|
FYCount := AYCount;
|
||||||
FDataPoints := ADataPoints;
|
FDataPoints := ADataPoints;
|
||||||
|
FOptions := AOptions;
|
||||||
sgData.RowCount := Max(ADataPoints.Count + 1, 2);
|
sgData.RowCount := Max(ADataPoints.Count + 1, 2);
|
||||||
for i := 1 to AYCount do
|
for i := 1 to AYCount do
|
||||||
with sgData.Columns.Add do begin
|
with sgData.Columns.Add do begin
|
||||||
@ -150,6 +182,7 @@ begin
|
|||||||
Index := i;
|
Index := i;
|
||||||
end;
|
end;
|
||||||
sgData.Columns.Delete(0); // remove the template column
|
sgData.Columns.Delete(0); // remove the template column
|
||||||
|
sgData.Columns[sgData.Columns.Count-2].Visible := not (dpeHideColorColumn in FOptions);
|
||||||
for i := 0 to ADataPoints.Count - 1 do
|
for i := 0 to ADataPoints.Count - 1 do
|
||||||
Split('|' + ADataPoints[i], sgData.Rows[i + 1]);
|
Split('|' + ADataPoints[i], sgData.Rows[i + 1]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user