How to determine if all axis labels are visible?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
jens.mertelmeyer
Newbie
Newbie
Posts: 60
Joined: Fri Nov 22, 2013 12:00 am

How to determine if all axis labels are visible?

Post by jens.mertelmeyer » Wed Sep 17, 2014 7:26 am

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.
1.png
The label in the middle got hidden
1.png (5.49 KiB) Viewed 6432 times
2.png
I've increased the chart's width a bit and now all labels are visible
2.png (6.7 KiB) Viewed 6433 times
My question is: How can I find out whether all labels are still visible or if some got hidden?

Many thanks in advance :)

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: How to determine if all axis labels are visible?

Post by Yeray » Thu Sep 18, 2014 8:53 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

jens.mertelmeyer
Newbie
Newbie
Posts: 60
Joined: Fri Nov 22, 2013 12:00 am

Re: How to determine if all axis labels are visible?

Post by jens.mertelmeyer » Thu Sep 18, 2014 9:00 am

The Items of the Axis, of course!

Thank you very much for this elaborate example :mrgreen:

Post Reply