From 71bbfef4d6c61a0cf1cb6b7808599b6dfad6546a Mon Sep 17 00:00:00 2001 From: ask Date: Sat, 15 Sep 2012 09:10:13 +0000 Subject: [PATCH] TAChart: Add TCustomAxisChartSource git-svn-id: trunk@38662 - --- .gitattributes | 1 + components/tachart/taaxissource.pas | 104 +++++++++++++++++++++++ components/tachart/tachartlazaruspkg.lpk | 6 +- components/tachart/tachartlazaruspkg.pas | 2 +- 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 components/tachart/taaxissource.pas diff --git a/.gitattributes b/.gitattributes index 18af3fb9f5..8fb1c2a3e2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3017,6 +3017,7 @@ components/tachart/numlib_fix/mdt.pas svneol=native#text/pascal components/tachart/numlib_fix/sle.pas svneol=native#text/pascal components/tachart/numlib_fix/spe.pas svneol=native#text/pascal components/tachart/taanimatedsource.pas svneol=native#text/pascal +components/tachart/taaxissource.pas svneol=native#text/pascal components/tachart/tachartaggpas.lpk svneol=native#text/pascal components/tachart/tachartaggpas.pas svneol=native#text/pascal components/tachart/tachartaxis.pas svneol=native#text/pascal diff --git a/components/tachart/taaxissource.pas b/components/tachart/taaxissource.pas new file mode 100644 index 0000000000..83162096ed --- /dev/null +++ b/components/tachart/taaxissource.pas @@ -0,0 +1,104 @@ +{ + + ***************************************************************************** + * * + * See the file COPYING.modifiedLGPL.txt, included in this distribution, * + * for details about the copyright. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * * + ***************************************************************************** + + Authors: Alexander Klenin + +} + +unit TAAxisSource; + +{$H+} + +interface + +uses + Classes, TACustomSource, TAChartAxis; + +type + TCustomAxisChartSource = class(TCustomChartSource) + strict private + FAxisFrom: TChartAxis; + FAxisTo: TChartAxis; + FItem: TChartDataItem; + protected + function GetCount: Integer; override; + function GetItem(AIndex: Integer): PChartDataItem; override; + procedure SetYCount(AValue: Cardinal); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + public + function IsSorted: Boolean; override; + + property AxisFrom: TChartAxis read FAxisFrom write FAxisFrom; + property AxisTo: TChartAxis read FAxisTo write FAxisTo; + end; + +implementation + +uses + TAChartUtils; + +{ TCustomAxisChartSource } + +constructor TCustomAxisChartSource.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FItem.Color := clTAColor; + FItem.YList := nil; +end; + +destructor TCustomAxisChartSource.Destroy; +begin + inherited Destroy; +end; + +function TCustomAxisChartSource.GetCount: Integer; +begin + if AxisFrom = nil then + Result := 0 + else + Result := AxisFrom.ValueCount; +end; + +function TCustomAxisChartSource.GetItem(AIndex: Integer): PChartDataItem; +var + v: Double; +begin + Result := @FItem; + if AxisFrom = nil then exit; + with AxisFrom.Value[AIndex] do begin + FItem.Text := FText; + v := FValue; + end; + if AxisFrom.Transformations <> nil then + v := AxisFrom.Transformations.AxisToGraph(v); + if (AxisTo <> nil) and (AxisTo.Transformations <> nil) then + v := AxisTo.Transformations.GraphToAxis(v); + FItem.X := v; + FItem.Y := v; +end; + +function TCustomAxisChartSource.IsSorted: Boolean; +begin + Result := true; +end; + +procedure TCustomAxisChartSource.SetYCount(AValue: Cardinal); +begin + Unused(AValue); + raise EYCountError.Create('Can not set YCount'); +end; + +end. + diff --git a/components/tachart/tachartlazaruspkg.lpk b/components/tachart/tachartlazaruspkg.lpk index 1e5a28b0d2..ecdf0c9e2d 100644 --- a/components/tachart/tachartlazaruspkg.lpk +++ b/components/tachart/tachartlazaruspkg.lpk @@ -34,7 +34,7 @@ for details about the copyright. "/> - + @@ -213,6 +213,10 @@ + + + + diff --git a/components/tachart/tachartlazaruspkg.pas b/components/tachart/tachartlazaruspkg.pas index 79669a4e31..04ed93dcf3 100644 --- a/components/tachart/tachartlazaruspkg.pas +++ b/components/tachart/tachartlazaruspkg.pas @@ -14,7 +14,7 @@ uses TADrawerCanvas, TADrawerSVG, TAIntervalSources, TAChartAxisUtils, TAChartListbox, TAEnumerators, TADataPointsEditor, TAChartExtentLink, TAToolEditors, TAMath, TAChartImageList, TADataTools, TAAnimatedSource, - TATextElements, LazarusPackageIntf; + TATextElements, TAAxisSource, LazarusPackageIntf; implementation