Page 1 of 1
How to determine if all axis labels are visible?
Posted: Wed Sep 17, 2014 7:26 am
by 16567885
Imagine a series (Bar Series) with every item having a label. We can set something like "labels -> min separation" of an axis. That's pretty cool. Instead of overlapping Labels, some are getting hidden.
- The label in the middle got hidden
- 1.png (5.49 KiB) Viewed 7064 times
- I've increased the chart's width a bit and now all labels are visible
- 2.png (6.7 KiB) Viewed 7065 times
My question is: How can I find out whether all labels are still visible or if some got hidden?
Many thanks in advance
Re: How to determine if all axis labels are visible?
Posted: Thu Sep 18, 2014 8:53 am
by yeray
Hi Jens,
You could check Chart1.Axes.Bottom.Items.Count as in the following example:
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
with Chart1.AddSeries(TBarSeries) do
begin
FillSampleValues(6);
Labels[0]:='Uno';
Labels[1]:='Dos';
Labels[2]:='Tres';
Labels[3]:='Cuatro';
Labels[4]:='Cinco';
Labels[5]:='Seis';
end;
TrackBar1.Max:=100;
TrackBar1.Min:=0;
TrackBar1.Position:=10;
TrackBar1.Frequency:=10;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
Chart1.Axes.Bottom.LabelsSeparation:=TrackBar1.Position;
Label1.Caption:='Separation: ' + IntToStr(TrackBar1.Position) + ' %';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IntToStr(Chart1.Axes.Bottom.Items.Count) + '/' + IntToStr(Chart1[0].Count) + ' labels drawn');
end;
Re: How to determine if all axis labels are visible?
Posted: Thu Sep 18, 2014 9:00 am
by 16567885
The
Items of the
Axis, of course!
Thank you very much for this elaborate example