Reputation: 11
I'm using TChart standard, version 8, and trying to find the actual TChartAxis.Increment value. From the doc: "Axis Increment is the minimum step between axis labels... If there is not enough space for all labels, TChart will calculate a bigger one". My problem is to find appropriate MinorTickCount value, or rather to coordinate it with the actual Increment. Because the default MinorTicks value (3) can looks strange if the increment is 5, for instance (in this case it's more natural to have 5 minor ticks). Thanks.
For instance, I set Increment to 1 and MinorTickCount to 0, but TChart increases increment to 5. If I knew that, I would set MinorTickCount to 4.
Upvotes: 0
Views: 1686
Reputation: 7452
You can achieve that with CalcIncrement method, for example:
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Chart1.AddSeries(TLineSeries).FillSampleValues();
TrackBar1.Max:=10;
TrackBar1.Position:=2;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var tmpIncr: Double;
begin
tmpIncr:=Chart1.Axes.Bottom.CalcIncrement;
if Chart1.Axes.Bottom.MinorTickCount<>tmpIncr-1 then
begin
Chart1.Axes.Bottom.MinorTickCount:=Trunc(tmpIncr-1);
Chart1.Draw;
end;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
Chart1.Axes.Bottom.Increment:=TrackBar1.Position;
Label1.Caption:='Bottom Axis Increment: ' + IntToStr(TrackBar1.Position);
end;
Upvotes: 1