TAChart: Add new property TickWidth to chart axis.

This commit is contained in:
wp_xyz 2021-11-04 10:36:54 +01:00
parent 647a86feb5
commit 6b24a4e57c
2 changed files with 19 additions and 2 deletions

View File

@ -22,6 +22,7 @@ uses
const
DEF_TICK_LENGTH = 4;
DEF_TICK_WIDTH = 1;
type
@ -43,6 +44,7 @@ type
published
property Marks: TChartMinorAxisMarks read GetMarks write SetMarks;
property TickLength default DEF_TICK_LENGTH div 2;
property TickWidth default DEF_TICK_WIDTH;
end;
TChartAxis = class;
@ -195,6 +197,7 @@ type
read FPositionUnits write SetPositionUnits default cuPercent;
property Range: TChartRange read FRange write SetRange;
property TickLength default DEF_TICK_LENGTH;
property TickWidth default DEF_TICK_WIDTH;
property Title: TChartAxisTitle read FTitle write SetTitle;
property Transformations: TChartAxisTransformations
read FTransformations write SetTransformations;
@ -352,6 +355,7 @@ begin
MinLength := 5;
end;
TickLength := DEF_TICK_LENGTH div 2;
TickWidth := DEF_TICK_WIDTH;
end;
function TChartMinorAxis.GetAlignment: TChartAxisAlignment;
@ -460,6 +464,7 @@ begin
FPositionUnits := cuPercent;
FRange := TChartRange.Create(ACollection.Owner as TCustomChart);
TickLength := DEF_TICK_LENGTH;
TickWidth := DEF_TICK_WIDTH;
FTitle := TChartAxisTitle.Create(ACollection.Owner as TCustomChart);
FMarginsForMarks := true;
FMarks.SetInsideDir(1, 0);

View File

@ -163,6 +163,7 @@ type
FTickColor: TColor;
FTickInnerLength: Integer;
FTickLength: Integer;
FTickWidth: Integer;
FVisible: Boolean;
function GetIntervals: TChartAxisIntervalParams;
procedure SetArrow(AValue: TChartArrow);
@ -171,6 +172,7 @@ type
procedure SetTickColor(AValue: TColor);
procedure SetTickInnerLength(AValue: Integer);
procedure SetTickLength(AValue: Integer);
procedure SetTickWidth(AValue: Integer);
procedure SetVisible(AValue: Boolean);
strict protected
FMarks: TCustomChartAxisMarks;
@ -199,6 +201,7 @@ type
property TickInnerLength: Integer
read FTickInnerLength write SetTickInnerLength default 0;
property TickLength: Integer read FTickLength write SetTickLength;
property TickWidth: Integer read FTickWidth write SetTickWidth;
property Visible: Boolean read FVisible write SetVisible default true;
end;
@ -344,6 +347,7 @@ procedure TAxisDrawHelper.DrawMark(
AFixedCoord: Integer; AMark: Double; const AText: String);
var
coord: Integer;
clr: TColor;
begin
coord := GraphToImage(AMark);
if
@ -364,9 +368,10 @@ begin
if FAxis.Marks.Visible then begin
if (FAxis.TickColor = clDefault) then
FDrawer.PrepareSimplePen(GetDefaultPenColor)
clr := GetDefaultPenColor
else
FDrawer.PrepareSimplePen(FAxis.TickColor);
clr := FAxis.TickColor;
FDrawer.SetPenParams(psSolid, clr, FAxis.TickWidth);
DrawLabelAndTick(coord, AFixedCoord, AText);
end;
end;
@ -807,6 +812,13 @@ begin
StyleChanged(Self);
end;
procedure TChartBasicAxis.SetTickWidth(AValue: Integer);
begin
if FTickWidth = AValue then exit;
FTickWidth := AValue;
StyleChanged(Self);
end;
procedure TChartBasicAxis.SetVisible(AValue: Boolean);
begin
if FVisible = AValue then exit;