Reduce the number of axis labels ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Reduce the number of axis labels ?

Post by moelski » Wed Feb 13, 2008 8:11 pm

Hi support,

we use several custom axis in our application. And in some cases there are to many labels at the axis.

Is it possible to set a maximum of labels per axis? This would be better readable for the user especially if you have more than three y-axis.

If needed I can post an exampleimage.

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

Post by Yeray » Thu Feb 14, 2008 11:03 am

Hi Dominik,

Here you have different options:

- You could simply modify the PositionPercent of the axes:

Code: Select all

  Chart1.MarginLeft := 15;
  Chart1.CustomAxes[0].PositionPercent := -8;
  Chart1.CustomAxes[1].PositionPercent := -16;
- You could use OnGetAxisLabel event to change LabelText manually. But note that here you need to set LabelStyle to talText (so, your values must have labeltext set).
In the following example I hide the even values (in order of points addition to series).

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Axes.Left.LabelStyle := talText;
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  if sender = Series1.GetVertAxis then
    if (ValueIndex < 0) or (ValueIndex mod 2 = 0) then
      LabelText := ''
    else
      LabelText := Series1.Labels[ValueIndex];
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Mar 03, 2008 11:25 am

Hi Yeray,

I´ve tested your solutions but that´s not what I need ...

Your first solution is not useable. It just sets some margins to the chart and the Axis.
Your second solution won´t work for me.

But I found a "half" solution in the meantime. It helps alot if I set the minimum distance (in %) at 100% for the axis label.

But this is only one step and there are other problems. See the following picture:
Image

I set the value format for both axis to #.##0,0 which is a common format in our application. If you have a big axis you will see double entries like on the picture.

This is really confusing for users.

So how can I disable the double values? It would be great if only the first one would be shown. So if yo have values like this:

Code: Select all

3,7
3,7
3,7
3,6
3,6
3,6
3,5
3,5
3,5
it sould be display in this form:

Code: Select all

           <-- deleted
           <-- deleted
3,7
           <-- deleted 
           <-- deleted
3,6
           <-- deleted
           <-- deleted
3,5
Could you please give me an example how to achieve this?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 03, 2008 11:52 am

Hi Dominik,

You could try setting specific Increment depending on what's displayed on your chart. In the image you sent you could try setting Increment to 0.1 to remove the labels you mentioned.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply