mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-01 22:19:39 +01:00
TAChart: Add TChartAxis.AxisPen property
git-svn-id: trunk@31718 -
This commit is contained in:
parent
c72795024c
commit
6742e22298
@ -80,6 +80,11 @@ type
|
||||
FTitleSize: Integer;
|
||||
end;
|
||||
|
||||
TChartAxisPen = class(TChartPen)
|
||||
published
|
||||
property Visible default false;
|
||||
end;
|
||||
|
||||
{ TChartAxis }
|
||||
|
||||
TChartAxis = class(TChartBasicAxis)
|
||||
@ -96,6 +101,7 @@ type
|
||||
FTitleRect: TRect;
|
||||
strict private
|
||||
FAlignment: TChartAxisAlignment;
|
||||
FAxisPen: TChartAxisPen;
|
||||
FGroup: Integer;
|
||||
FHelper: TAxisDrawHelper;
|
||||
FInverted: Boolean;
|
||||
@ -106,6 +112,7 @@ type
|
||||
FZPosition: TChartDistance;
|
||||
|
||||
function GetTransform: TChartAxisTransformations;
|
||||
procedure SetAxisPen(AValue: TChartAxisPen);
|
||||
procedure SetGroup(AValue: Integer);
|
||||
procedure SetInverted(AValue: Boolean);
|
||||
procedure SetMinors(AValue: TChartMinorAxisList);
|
||||
@ -136,6 +143,7 @@ type
|
||||
AClipRect: PRect; AMaxZPosition: Integer);
|
||||
published
|
||||
property Alignment default calLeft;
|
||||
property AxisPen: TChartAxisPen read FAxisPen write SetAxisPen;
|
||||
property Group: Integer read FGroup write SetGroup default 0;
|
||||
// Inverts the axis scale from increasing to decreasing.
|
||||
property Inverted: boolean read FInverted write SetInverted default false;
|
||||
@ -360,6 +368,9 @@ end;
|
||||
constructor TChartAxis.Create(ACollection: TCollection);
|
||||
begin
|
||||
inherited Create(ACollection, ACollection.Owner as TCustomChart);
|
||||
FAxisPen := TChartAxisPen.Create;
|
||||
FAxisPen.OnChange := @StyleChanged;
|
||||
FAxisPen.Visible := false;
|
||||
FListener := TListener.Create(@FTransformations, @StyleChanged);
|
||||
FMinors := TChartMinorAxisList.Create(Self);
|
||||
TickLength := DEF_TICK_LENGTH;
|
||||
@ -372,6 +383,7 @@ begin
|
||||
FreeAndNil(FMinors);
|
||||
FreeAndNil(FListener);
|
||||
FreeAndNil(FHelper);
|
||||
FreeAndNil(FAxisPen);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -388,6 +400,10 @@ begin
|
||||
fixedCoord := TChartAxisMargins(FAxisRect)[Alignment];
|
||||
v := 0;
|
||||
FHelper.BeginDrawing;
|
||||
if AxisPen.Visible then begin;
|
||||
FHelper.FDrawer.Pen := AxisPen;
|
||||
FHelper.DrawAxisLine(fixedCoord);
|
||||
end;
|
||||
axisTransf := @GetTransform.AxisToGraph;
|
||||
for i := 0 to High(FMarkValues) do begin
|
||||
pv := v;
|
||||
@ -586,6 +602,12 @@ begin
|
||||
StyleChanged(Self);
|
||||
end;
|
||||
|
||||
procedure TChartAxis.SetAxisPen(AValue: TChartAxisPen);
|
||||
begin
|
||||
FAxisPen.Assign(AValue);
|
||||
StyleChanged(Self);
|
||||
end;
|
||||
|
||||
procedure TChartAxis.SetGroup(AValue: Integer);
|
||||
begin
|
||||
if FGroup = AValue then exit;
|
||||
@ -602,7 +624,6 @@ end;
|
||||
|
||||
procedure TChartAxis.SetMinors(AValue: TChartMinorAxisList);
|
||||
begin
|
||||
if FMinors = AValue then exit;
|
||||
FMinors.Assign(AValue);
|
||||
StyleChanged(Self);
|
||||
end;
|
||||
|
||||
@ -78,7 +78,7 @@ type
|
||||
TChartAxisMarkToTextEvent =
|
||||
procedure (var AText: String; AMark: Double) of object;
|
||||
|
||||
TChartAxisPen = class(TChartPen)
|
||||
TChartAxisGridPen = class(TChartPen)
|
||||
published
|
||||
property Style default psDot;
|
||||
end;
|
||||
@ -124,12 +124,12 @@ type
|
||||
|
||||
TChartBasicAxis = class(TCollectionItem)
|
||||
strict private
|
||||
FGrid: TChartAxisPen;
|
||||
FGrid: TChartAxisGridPen;
|
||||
FMarks: TChartAxisMarks;
|
||||
FTickColor: TColor;
|
||||
FTickLength: Integer;
|
||||
FVisible: Boolean;
|
||||
procedure SetGrid(AValue: TChartAxisPen);
|
||||
procedure SetGrid(AValue: TChartAxisGridPen);
|
||||
procedure SetMarks(AValue: TChartAxisMarks);
|
||||
procedure SetTickColor(AValue: TColor);
|
||||
procedure SetTickLength(AValue: Integer);
|
||||
@ -149,7 +149,7 @@ type
|
||||
read GetAlignment write SetAlignment;
|
||||
property Marks: TChartAxisMarks read FMarks write SetMarks;
|
||||
published
|
||||
property Grid: TChartAxisPen read FGrid write SetGrid;
|
||||
property Grid: TChartAxisGridPen read FGrid write SetGrid;
|
||||
property TickColor: TColor read FTickColor write SetTickColor default clBlack;
|
||||
property TickLength: Integer read FTickLength write SetTickLength;
|
||||
property Visible: Boolean read FVisible write SetVisible default true;
|
||||
@ -181,6 +181,7 @@ type
|
||||
procedure BeginDrawing; virtual;
|
||||
function Clone: TAxisDrawHelper;
|
||||
constructor Create; virtual;
|
||||
procedure DrawAxisLine(AFixedCoord: Integer); virtual; abstract;
|
||||
procedure DrawMark(
|
||||
AFixedCoord: Integer; AMark: Double; const AText: String);
|
||||
procedure EndDrawing; virtual; abstract;
|
||||
@ -200,6 +201,7 @@ type
|
||||
procedure GridLine(ACoord: Integer); override;
|
||||
public
|
||||
procedure BeginDrawing; override;
|
||||
procedure DrawAxisLine(AFixedCoord: Integer); override;
|
||||
procedure EndDrawing; override;
|
||||
procedure GetClipRange(out AMin, AMax: Integer); override;
|
||||
end;
|
||||
@ -214,6 +216,7 @@ type
|
||||
procedure GridLine(ACoord: Integer); override;
|
||||
public
|
||||
procedure BeginDrawing; override;
|
||||
procedure DrawAxisLine(AFixedCoord: Integer); override;
|
||||
procedure EndDrawing; override;
|
||||
procedure GetClipRange(out AMin, AMax: Integer); override;
|
||||
end;
|
||||
@ -306,6 +309,12 @@ begin
|
||||
FPrevCoord := FClipRect^.Left;
|
||||
end;
|
||||
|
||||
procedure TAxisDrawHelperX.DrawAxisLine(AFixedCoord: Integer);
|
||||
begin
|
||||
LineZ(
|
||||
Point(FClipRect^.Left, AFixedCoord), Point(FClipRect^.Right, AFixedCoord));
|
||||
end;
|
||||
|
||||
procedure TAxisDrawHelperX.DrawLabelAndTick(
|
||||
ACoord, AFixedCoord: Integer; const AText: String);
|
||||
var
|
||||
@ -352,6 +361,12 @@ begin
|
||||
FPrevCoord := FClipRect^.Bottom;
|
||||
end;
|
||||
|
||||
procedure TAxisDrawHelperY.DrawAxisLine(AFixedCoord: Integer);
|
||||
begin
|
||||
LineZ(
|
||||
Point(AFixedCoord, FClipRect^.Top), Point(AFixedCoord, FClipRect^.Bottom));
|
||||
end;
|
||||
|
||||
procedure TAxisDrawHelperY.DrawLabelAndTick(
|
||||
ACoord, AFixedCoord: Integer; const AText: String);
|
||||
var
|
||||
@ -508,7 +523,7 @@ constructor TChartBasicAxis.Create(
|
||||
ACollection: TCollection; AChart: TCustomChart);
|
||||
begin
|
||||
inherited Create(ACollection);
|
||||
FGrid := TChartAxisPen.Create;
|
||||
FGrid := TChartAxisGridPen.Create;
|
||||
FGrid.OnChange := @StyleChanged;
|
||||
FGrid.Style := psDot;
|
||||
FMarks := TChartAxisMarks.Create(AChart);
|
||||
@ -523,7 +538,7 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TChartBasicAxis.SetGrid(AValue: TChartAxisPen);
|
||||
procedure TChartBasicAxis.SetGrid(AValue: TChartAxisGridPen);
|
||||
begin
|
||||
FGrid.Assign(AValue);
|
||||
StyleChanged(Self);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user