mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 21:36:27 +02:00
TAChart: Add axis index property editor
git-svn-id: trunk@38668 -
This commit is contained in:
parent
8594b7a678
commit
f297a8e800
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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.pas svneol=native#text/pascal
|
||||
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.pas svneol=native#text/pascal
|
||||
components/tachart/editors/tatooleditors.pas svneol=native#text/pascal
|
||||
|
78
components/tachart/editors/taseriespropeditors.pas
Normal file
78
components/tachart/editors/taseriespropeditors.pas
Normal 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.
|
||||
|
@ -160,6 +160,7 @@ type
|
||||
ADrawer: IChartDrawer; const ATransf: ICoordTransformer;
|
||||
AClipRect: PRect; AMaxZPosition: Integer);
|
||||
procedure UpdateBounds(var AMin, AMax: Double);
|
||||
property DisplayName: String read GetDisplayName;
|
||||
property Value[AIndex: Integer]: TChartValueText read GetValue;
|
||||
property ValueCount: Integer read GetValueCount;
|
||||
published
|
||||
@ -538,7 +539,7 @@ begin
|
||||
Result := Collection.Owner as TCustomChart;
|
||||
end;
|
||||
|
||||
function TChartAxis.GetDisplayName: string;
|
||||
function TChartAxis.GetDisplayName: String;
|
||||
const
|
||||
SIDE_NAME: array [TChartAxisAlignment] of String =
|
||||
('Left', 'Top', 'Right', 'Bottom');
|
||||
|
@ -34,7 +34,7 @@
|
||||
for details about the copyright.
|
||||
"/>
|
||||
<Version Major="1"/>
|
||||
<Files Count="41">
|
||||
<Files Count="42">
|
||||
<Item1>
|
||||
<Filename Value="tagraph.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
@ -217,6 +217,11 @@
|
||||
<Filename Value="taaxissource.pas"/>
|
||||
<UnitName Value="TAAxisSource"/>
|
||||
</Item41>
|
||||
<Item42>
|
||||
<Filename Value="editors\taseriespropeditors.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="TASeriesPropEditors"/>
|
||||
</Item42>
|
||||
</Files>
|
||||
<LazDoc Paths="$(LazarusDir)\components\tachart\fpdoc"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
|
@ -14,7 +14,7 @@ uses
|
||||
TADrawerCanvas, TADrawerSVG, TAIntervalSources, TAChartAxisUtils,
|
||||
TAChartListbox, TAEnumerators, TADataPointsEditor, TAChartExtentLink,
|
||||
TAToolEditors, TAMath, TAChartImageList, TADataTools, TAAnimatedSource,
|
||||
TATextElements, TAAxisSource, LazarusPackageIntf;
|
||||
TATextElements, TAAxisSource, TASeriesPropEditors, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
@ -35,6 +35,7 @@ begin
|
||||
RegisterUnit('TAChartExtentLink', @TAChartExtentLink.Register);
|
||||
RegisterUnit('TAToolEditors', @TAToolEditors.Register);
|
||||
RegisterUnit('TAChartImageList', @TAChartImageList.Register);
|
||||
RegisterUnit('TASeriesPropEditors', @TASeriesPropEditors.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@ -44,16 +44,18 @@ type
|
||||
FValue: TDoublePoint;
|
||||
end;
|
||||
|
||||
TChartAxisIndex = -1..MaxInt;
|
||||
|
||||
{ TCustomChartSeries }
|
||||
|
||||
TCustomChartSeries = class(TBasicChartSeries)
|
||||
strict private
|
||||
FAxisIndexX: Integer;
|
||||
FAxisIndexY: Integer;
|
||||
FAxisIndexX: TChartAxisIndex;
|
||||
FAxisIndexY: TChartAxisIndex;
|
||||
FLegend: TChartSeriesLegend;
|
||||
FTitle: String;
|
||||
procedure SetAxisIndexX(AValue: Integer);
|
||||
procedure SetAxisIndexY(AValue: Integer);
|
||||
procedure SetAxisIndexX(AValue: TChartAxisIndex);
|
||||
procedure SetAxisIndexY(AValue: TChartAxisIndex);
|
||||
procedure SetLegend(AValue: TChartSeriesLegend);
|
||||
procedure SetShowInLegend(AValue: Boolean);
|
||||
|
||||
@ -104,9 +106,9 @@ type
|
||||
procedure GetSingleLegendItem(AItems: TChartLegendItems);
|
||||
function HasParent: Boolean; override;
|
||||
|
||||
property AxisIndexX: Integer
|
||||
property AxisIndexX: TChartAxisIndex
|
||||
read FAxisIndexX write SetAxisIndexX default DEF_AXIS_INDEX;
|
||||
property AxisIndexY: Integer
|
||||
property AxisIndexY: TChartAxisIndex
|
||||
read FAxisIndexY write SetAxisIndexY default DEF_AXIS_INDEX;
|
||||
property Title: String read FTitle write SetTitle stored TitleIsStored;
|
||||
|
||||
@ -472,14 +474,14 @@ begin
|
||||
UpdateParentChart;
|
||||
end;
|
||||
|
||||
procedure TCustomChartSeries.SetAxisIndexX(AValue: Integer);
|
||||
procedure TCustomChartSeries.SetAxisIndexX(AValue: TChartAxisIndex);
|
||||
begin
|
||||
if FAxisIndexX = AValue then exit;
|
||||
FAxisIndexX := AValue;
|
||||
UpdateParentChart;
|
||||
end;
|
||||
|
||||
procedure TCustomChartSeries.SetAxisIndexY(AValue: Integer);
|
||||
procedure TCustomChartSeries.SetAxisIndexY(AValue: TChartAxisIndex);
|
||||
begin
|
||||
if FAxisIndexY = AValue then exit;
|
||||
FAxisIndexY := AValue;
|
||||
|
Loading…
Reference in New Issue
Block a user