TAChart: Add axis index property editor

git-svn-id: trunk@38668 -
This commit is contained in:
ask 2012-09-15 14:22:51 +00:00
parent 8594b7a678
commit f297a8e800
6 changed files with 99 additions and 11 deletions

1
.gitattributes vendored
View File

@ -2979,6 +2979,7 @@ components/tachart/demo/wmf/wmfdemo.lpr svneol=native#text/pascal
components/tachart/editors/tadatapointseditor.lfm svneol=native#text/plain components/tachart/editors/tadatapointseditor.lfm svneol=native#text/plain
components/tachart/editors/tadatapointseditor.pas svneol=native#text/pascal components/tachart/editors/tadatapointseditor.pas svneol=native#text/pascal
components/tachart/editors/taserieseditor.pas svneol=native#text/plain components/tachart/editors/taserieseditor.pas svneol=native#text/plain
components/tachart/editors/taseriespropeditors.pas svneol=native#text/pascal
components/tachart/editors/tasubcomponentseditor.lfm svneol=native#text/plain components/tachart/editors/tasubcomponentseditor.lfm svneol=native#text/plain
components/tachart/editors/tasubcomponentseditor.pas svneol=native#text/pascal components/tachart/editors/tasubcomponentseditor.pas svneol=native#text/pascal
components/tachart/editors/tatooleditors.pas svneol=native#text/pascal components/tachart/editors/tatooleditors.pas svneol=native#text/pascal

View File

@ -0,0 +1,78 @@
unit TASeriesPropEditors;
{$H+}
interface
procedure Register;
implementation
uses
Classes, Math, PropEdits, SysUtils, TACustomSeries, TAGraph;
type
TAxisIndexPropertyEditor = class(TOrdinalPropertyEditor)
public
function GetAttributes: TPropertyAttributes; override;
function OrdValueToVisualValue(AOrdValue: Longint): String; override;
procedure GetValues(AProc: TGetStrProc); override;
procedure SetValue(const ANewValue: String); override;
end;
procedure Register;
begin
RegisterPropertyEditor(
TypeInfo(TChartAxisIndex), TCustomChartSeries, '', TAxisIndexPropertyEditor);
end;
{ TAxisIndexPropertyEditor }
function TAxisIndexPropertyEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paRevertable];
if GetDefaultOrdValue <> NoDefaultValue then
Result := Result + [paHasDefaultValue];
end;
procedure TAxisIndexPropertyEditor.GetValues(AProc: TGetStrProc);
var
s: TCustomChartSeries;
ch: TChart;
i: Integer;
begin
s := GetComponent(0) as TCustomChartSeries;
ch := s.ParentChart;
AProc('-1 None');
for i := 0 to ch.AxisList.Count - 1 do
AProc(IntToStr(i) + ' ' + ch.AxisList[i].DisplayName);
end;
function TAxisIndexPropertyEditor.OrdValueToVisualValue(
AOrdValue: Longint): String;
var
s: TCustomChartSeries;
ch: TChart;
begin
s := GetComponent(0) as TCustomChartSeries;
ch := s.ParentChart;
Result := IntToStr(AOrdValue) + ' ';
if InRange(AOrdValue, 0, ch.AxisList.Count - 1) then
Result += ch.AxisList[AOrdValue].DisplayName
else
Result += 'None';
end;
procedure TAxisIndexPropertyEditor.SetValue(const ANewValue: String);
var
v: Integer;
code: Word;
begin
Val(ANewValue, v, code);
if code > 0 then
Val(Copy(ANewValue, 1, code - 1), v, code);
SetOrdValue(Max(v, Low(TChartAxisIndex)));
end;
end.

View File

@ -160,6 +160,7 @@ type
ADrawer: IChartDrawer; const ATransf: ICoordTransformer; ADrawer: IChartDrawer; const ATransf: ICoordTransformer;
AClipRect: PRect; AMaxZPosition: Integer); AClipRect: PRect; AMaxZPosition: Integer);
procedure UpdateBounds(var AMin, AMax: Double); procedure UpdateBounds(var AMin, AMax: Double);
property DisplayName: String read GetDisplayName;
property Value[AIndex: Integer]: TChartValueText read GetValue; property Value[AIndex: Integer]: TChartValueText read GetValue;
property ValueCount: Integer read GetValueCount; property ValueCount: Integer read GetValueCount;
published published
@ -538,7 +539,7 @@ begin
Result := Collection.Owner as TCustomChart; Result := Collection.Owner as TCustomChart;
end; end;
function TChartAxis.GetDisplayName: string; function TChartAxis.GetDisplayName: String;
const const
SIDE_NAME: array [TChartAxisAlignment] of String = SIDE_NAME: array [TChartAxisAlignment] of String =
('Left', 'Top', 'Right', 'Bottom'); ('Left', 'Top', 'Right', 'Bottom');

View File

@ -34,7 +34,7 @@
for details about the copyright. for details about the copyright.
"/> "/>
<Version Major="1"/> <Version Major="1"/>
<Files Count="41"> <Files Count="42">
<Item1> <Item1>
<Filename Value="tagraph.pas"/> <Filename Value="tagraph.pas"/>
<HasRegisterProc Value="True"/> <HasRegisterProc Value="True"/>
@ -217,6 +217,11 @@
<Filename Value="taaxissource.pas"/> <Filename Value="taaxissource.pas"/>
<UnitName Value="TAAxisSource"/> <UnitName Value="TAAxisSource"/>
</Item41> </Item41>
<Item42>
<Filename Value="editors\taseriespropeditors.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="TASeriesPropEditors"/>
</Item42>
</Files> </Files>
<LazDoc Paths="$(LazarusDir)\components\tachart\fpdoc"/> <LazDoc Paths="$(LazarusDir)\components\tachart\fpdoc"/>
<Type Value="RunAndDesignTime"/> <Type Value="RunAndDesignTime"/>

View File

@ -14,7 +14,7 @@ uses
TADrawerCanvas, TADrawerSVG, TAIntervalSources, TAChartAxisUtils, TADrawerCanvas, TADrawerSVG, TAIntervalSources, TAChartAxisUtils,
TAChartListbox, TAEnumerators, TADataPointsEditor, TAChartExtentLink, TAChartListbox, TAEnumerators, TADataPointsEditor, TAChartExtentLink,
TAToolEditors, TAMath, TAChartImageList, TADataTools, TAAnimatedSource, TAToolEditors, TAMath, TAChartImageList, TADataTools, TAAnimatedSource,
TATextElements, TAAxisSource, LazarusPackageIntf; TATextElements, TAAxisSource, TASeriesPropEditors, LazarusPackageIntf;
implementation implementation
@ -35,6 +35,7 @@ begin
RegisterUnit('TAChartExtentLink', @TAChartExtentLink.Register); RegisterUnit('TAChartExtentLink', @TAChartExtentLink.Register);
RegisterUnit('TAToolEditors', @TAToolEditors.Register); RegisterUnit('TAToolEditors', @TAToolEditors.Register);
RegisterUnit('TAChartImageList', @TAChartImageList.Register); RegisterUnit('TAChartImageList', @TAChartImageList.Register);
RegisterUnit('TASeriesPropEditors', @TASeriesPropEditors.Register);
end; end;
initialization initialization

View File

@ -44,16 +44,18 @@ type
FValue: TDoublePoint; FValue: TDoublePoint;
end; end;
TChartAxisIndex = -1..MaxInt;
{ TCustomChartSeries } { TCustomChartSeries }
TCustomChartSeries = class(TBasicChartSeries) TCustomChartSeries = class(TBasicChartSeries)
strict private strict private
FAxisIndexX: Integer; FAxisIndexX: TChartAxisIndex;
FAxisIndexY: Integer; FAxisIndexY: TChartAxisIndex;
FLegend: TChartSeriesLegend; FLegend: TChartSeriesLegend;
FTitle: String; FTitle: String;
procedure SetAxisIndexX(AValue: Integer); procedure SetAxisIndexX(AValue: TChartAxisIndex);
procedure SetAxisIndexY(AValue: Integer); procedure SetAxisIndexY(AValue: TChartAxisIndex);
procedure SetLegend(AValue: TChartSeriesLegend); procedure SetLegend(AValue: TChartSeriesLegend);
procedure SetShowInLegend(AValue: Boolean); procedure SetShowInLegend(AValue: Boolean);
@ -104,9 +106,9 @@ type
procedure GetSingleLegendItem(AItems: TChartLegendItems); procedure GetSingleLegendItem(AItems: TChartLegendItems);
function HasParent: Boolean; override; function HasParent: Boolean; override;
property AxisIndexX: Integer property AxisIndexX: TChartAxisIndex
read FAxisIndexX write SetAxisIndexX default DEF_AXIS_INDEX; read FAxisIndexX write SetAxisIndexX default DEF_AXIS_INDEX;
property AxisIndexY: Integer property AxisIndexY: TChartAxisIndex
read FAxisIndexY write SetAxisIndexY default DEF_AXIS_INDEX; read FAxisIndexY write SetAxisIndexY default DEF_AXIS_INDEX;
property Title: String read FTitle write SetTitle stored TitleIsStored; property Title: String read FTitle write SetTitle stored TitleIsStored;
@ -472,14 +474,14 @@ begin
UpdateParentChart; UpdateParentChart;
end; end;
procedure TCustomChartSeries.SetAxisIndexX(AValue: Integer); procedure TCustomChartSeries.SetAxisIndexX(AValue: TChartAxisIndex);
begin begin
if FAxisIndexX = AValue then exit; if FAxisIndexX = AValue then exit;
FAxisIndexX := AValue; FAxisIndexX := AValue;
UpdateParentChart; UpdateParentChart;
end; end;
procedure TCustomChartSeries.SetAxisIndexY(AValue: Integer); procedure TCustomChartSeries.SetAxisIndexY(AValue: TChartAxisIndex);
begin begin
if FAxisIndexY = AValue then exit; if FAxisIndexY = AValue then exit;
FAxisIndexY := AValue; FAxisIndexY := AValue;