diff --git a/.gitattributes b/.gitattributes
index 8abc400d5f..a4cd385e20 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2495,6 +2495,8 @@ components/tachart/tachartwmf.lpk svneol=native#text/plain
components/tachart/tachartwmf.pas svneol=native#text/pascal
components/tachart/tacustomseries.pas svneol=native#text/plain
components/tachart/tacustomsource.pas svneol=native#text/pascal
+components/tachart/tadatapointseditor.lfm svneol=native#text/plain
+components/tachart/tadatapointseditor.pas svneol=native#text/pascal
components/tachart/tadbsource.pas svneol=native#text/pascal
components/tachart/tadraweraggpas.pas svneol=native#text/pascal
components/tachart/tadrawerbgra.pas svneol=native#text/pascal
diff --git a/components/tachart/tachartlazaruspkg.lpk b/components/tachart/tachartlazaruspkg.lpk
index 8516ab202d..fb2835205b 100644
--- a/components/tachart/tachartlazaruspkg.lpk
+++ b/components/tachart/tachartlazaruspkg.lpk
@@ -30,7 +30,7 @@
for details about the copyright.
"/>
-
+
@@ -164,6 +164,11 @@
+
+
+
+
+
diff --git a/components/tachart/tachartlazaruspkg.pas b/components/tachart/tachartlazaruspkg.pas
index c5c7453372..4aa9807cd7 100644
--- a/components/tachart/tachartlazaruspkg.pas
+++ b/components/tachart/tachartlazaruspkg.pas
@@ -12,7 +12,7 @@ uses
TATypes, TADrawUtils, TAMultiSeries, TALegend, TAStyles, TAFuncSeries,
TALegendPanel, TARadialSeries, TACustomSource, TAGeometry, TANavigation,
TADrawerCanvas, TADrawerSVG, TAIntervalSources, TAChartAxisUtils,
- TAChartListbox, TAEnumerators, LazarusPackageIntf;
+ TAChartListbox, TAEnumerators, TADataPointsEditor, LazarusPackageIntf;
implementation
@@ -29,6 +29,7 @@ begin
RegisterUnit('TANavigation', @TANavigation.Register);
RegisterUnit('TAIntervalSources', @TAIntervalSources.Register);
RegisterUnit('TAChartListbox', @TAChartListbox.Register);
+ RegisterUnit('TADataPointsEditor', @TADataPointsEditor.Register);
end;
initialization
diff --git a/components/tachart/tadatapointseditor.lfm b/components/tachart/tadatapointseditor.lfm
new file mode 100644
index 0000000000..57f5852946
--- /dev/null
+++ b/components/tachart/tadatapointseditor.lfm
@@ -0,0 +1,49 @@
+object DataPointsEditorForm: TDataPointsEditorForm
+ Left = 418
+ Height = 303
+ Top = 235
+ Width = 357
+ Caption = 'DataPoints editor'
+ ClientHeight = 303
+ ClientWidth = 357
+ LCLVersion = '0.9.31'
+ object sgData: TStringGrid
+ Left = 0
+ Height = 257
+ Top = 0
+ Width = 357
+ Align = alClient
+ Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goRowMoving, goEditing, goAutoAddRows, goRowSelect, goAlwaysShowEditor, goSmoothScroll, goFixedRowNumbering]
+ PopupMenu = pmRows
+ TabOrder = 0
+ end
+ object ButtonPanel1: TButtonPanel
+ Left = 6
+ Height = 34
+ Top = 263
+ Width = 345
+ OKButton.Name = 'OKButton'
+ OKButton.Caption = '&OK'
+ HelpButton.Name = 'HelpButton'
+ HelpButton.Caption = '&Help'
+ CloseButton.Name = 'CloseButton'
+ CloseButton.Caption = '&Close'
+ CancelButton.Name = 'CancelButton'
+ CancelButton.Caption = 'Cancel'
+ TabOrder = 1
+ ShowButtons = [pbOK, pbCancel]
+ end
+ object pmRows: TPopupMenu
+ OnPopup = pmRowsPopup
+ left = 193
+ top = 124
+ object miInsertRow: TMenuItem
+ Caption = 'Insert row'
+ OnClick = miInsertRowClick
+ end
+ object miDeleteRow: TMenuItem
+ Caption = 'Delete row'
+ OnClick = miDeleteRowClick
+ end
+ end
+end
diff --git a/components/tachart/tadatapointseditor.pas b/components/tachart/tadatapointseditor.pas
new file mode 100644
index 0000000000..a98632bb9b
--- /dev/null
+++ b/components/tachart/tadatapointseditor.pas
@@ -0,0 +1,153 @@
+unit TADataPointsEditor;
+
+{$H+}
+
+interface
+
+uses
+ ButtonPanel, Classes, ExtCtrls, Grids, Menus, SysUtils, FileUtil, Forms,
+ Controls, Graphics, Dialogs;
+
+type
+ TDataPointsEditorForm = class(TForm)
+ ButtonPanel1: TButtonPanel;
+ miInsertRow: TMenuItem;
+ miDeleteRow: TMenuItem;
+ pmRows: TPopupMenu;
+ sgData: TStringGrid;
+ procedure miDeleteRowClick(Sender: TObject);
+ procedure miInsertRowClick(Sender: TObject);
+ procedure pmRowsPopup(Sender: TObject);
+ strict private
+ FCurrentRow: Integer;
+ FDataPoints: TStrings;
+ FYCount: Integer;
+ public
+ procedure InitData(AYCount: Integer; ADataPoints: TStrings);
+ procedure ExtractData;
+ end;
+
+procedure Register;
+
+implementation
+
+uses
+ Math, PropEdits, TASources;
+
+{$R *.lfm}
+
+type
+ TDataPointsPropertyEditor = class(TPropertyEditor)
+ public
+ procedure Edit; override;
+ function GetAttributes: TPropertyAttributes; override;
+ function GetValue: AnsiString; override;
+ end;
+
+procedure Register;
+begin
+ RegisterPropertyEditor(
+ TypeInfo(TStrings), TListChartSource, 'DataPoints',
+ TDataPointsPropertyEditor);
+end;
+
+{ TDataPointsEditorForm }
+
+procedure TDataPointsEditorForm.ExtractData;
+var
+ i: Integer;
+ s: String;
+begin
+ FDataPoints.BeginUpdate;
+ try
+ FDataPoints.Clear;
+ for i := 1 to sgData.RowCount - 1 do begin
+ with sgData.Rows[i] do begin
+ Delimiter := '|';
+ StrictDelimiter := true;
+ s := DelimitedText;
+ end;
+ if Length(s) >= sgData.ColCount then
+ FDataPoints.Add(Copy(s, 2, MaxInt));
+ end;
+ finally
+ FDataPoints.EndUpdate;
+ end;
+end;
+
+procedure TDataPointsEditorForm.InitData(
+ AYCount: Integer; ADataPoints: TStrings);
+var
+ i: Integer;
+begin
+ FYCount := AYCount;
+ FDataPoints := ADataPoints;
+ sgData.ColCount := AYCount + 4;
+ sgData.RowCount := Max(ADataPoints.Count + 1, 2);
+ sgData.Cells[0, 0] := 'No.';
+ sgData.Cells[1, 0] := 'X';
+ sgData.Cells[2, 0] := 'Y';
+ for i := 2 to AYCount do
+ sgData.Cells[i + 1, 0] := 'Y' + IntToStr(i);
+ sgData.Cells[AYCount + 2, 0] := 'Color';
+ sgData.Cells[AYCount + 3, 0] := 'Text';
+ for i := 0 to ADataPoints.Count - 1 do
+ with sgData.Rows[i + 1] do begin
+ Delimiter := '|';
+ StrictDelimiter := true;
+ DelimitedText := '|' + ADataPoints[i];
+ end;
+end;
+
+procedure TDataPointsEditorForm.miDeleteRowClick(Sender: TObject);
+begin
+ if sgData.RowCount <= 2 then begin
+ sgData.Rows[1].Clear;
+ exit;
+ end;
+ if InRange(FCurrentRow, 1, sgData.RowCount - 1) then begin
+ sgData.DeleteRow(FCurrentRow);
+ end;
+end;
+
+procedure TDataPointsEditorForm.miInsertRowClick(Sender: TObject);
+begin
+ sgData.InsertColRow(false, FCurrentRow);
+end;
+
+procedure TDataPointsEditorForm.pmRowsPopup(Sender: TObject);
+begin
+ FCurrentRow := sgData.MouseToCell(sgData.ScreenToClient(Mouse.CursorPos)).Y;
+ if not InRange(FCurrentRow, 1, sgData.RowCount - 1) then
+ Abort;
+ sgData.Row := FCurrentRow;
+end;
+
+{ TDataPointsPropertyEditor }
+
+procedure TDataPointsPropertyEditor.Edit;
+begin
+ with TDataPointsEditorForm.Create(nil) do
+ try
+ InitData(
+ (GetComponent(0) as TListChartSource).YCount,
+ GetObjectValue as TStrings);
+ if ShowModal = mrOK then
+ ExtractData;
+ finally
+ Free;
+ end;
+end;
+
+function TDataPointsPropertyEditor.GetAttributes: TPropertyAttributes;
+begin
+ Result := [paDialog, paMultiSelect, paReadOnly, paRevertable];
+end;
+
+function TDataPointsPropertyEditor.GetValue: AnsiString;
+begin
+ Result := (GetObjectValue as TStrings).Text;
+end;
+
+end.
+