MaxLabelsWidth returns wrong value

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:

MaxLabelsWidth returns wrong value

Post by moelski » Mon Jul 02, 2007 12:27 pm

Hi !

I have 6 series which use all the left axis.
Now I use this code to assign a customaxis to each serie.

Code: Select all

  for Nr := 0 to Chart1.SeriesCount - 1 do begin
    Chart1[Nr].CustomVertAxis := Chart1.CustomAxes.Items[Nr];
    Chart1.CustomAxes.Items[Nr].Visible := True;
  end;
If I use Chart1.Series[Nr].GetVertAxis.MaxLabelsWidth I got 9 as result. All maximum values from the axis are 0.

How can I recalculate the corrent axis values so that MaxLabelsWidth works correct?

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 Jul 02, 2007 1:11 pm

Hi Dominik,

This works fine for me here doing something like this:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
  begin
    Chart1[i].FillSampleValues();
    Chart1[i].CustomVertAxis:=Chart1.CustomAxes[i];
  end;

  Chart1.MarginLeft:=5;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
    Chart1.Title.Text.add(IntToStr(Chart1[i].GetVertAxis.MaxLabelsWidth));
end;
If this doesn't help please send us a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.
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

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

Post by moelski » Mon Jul 02, 2007 1:37 pm

Hi Narcis,

I´ve uploaded a file to the server:
Received Axis Demo 2.zip Content Type application/x-zip-compressed Length 27787
Here are the steps for reproducing :
1) Check "START"
2) After some seconds Uncheck "START"
3) Use Change VIEW -> "one Y-Axis for all Series"
4) Use Change VIEW -> "one Y-Axis per Series"

If you step through procedure TForm1.PlaceLVAxis; during step 4) you can see that Achse.MaxLabelsWidth is 9. This is because the maximum value of each axis is 0.

So what can I do ?

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 Jul 02, 2007 2:27 pm

Hi Dominik,

Thanks for the example but I don't see what effect does it make to your project. You may want to try calling Chart1.Draw so axes are properly drawn or ca.AdjustMaxMin. It this doesn't help please give us some more information about the exact problem.

Thanks in advance.
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

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

Post by moelski » Mon Jul 02, 2007 5:56 pm

Hi Narcis,

Code: Select all

ca.AdjustMaxMin
That´s what I´m searching for.

Thx alot !

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

Post by moelski » Mon Jul 02, 2007 7:05 pm

Hi Narcís,

there is one problem left. Hopefully you can give me a tip.
I uploaded a new and smaller demo application to your server:
Received Axis Demo 2_2.zip Content Type application/x-zip-compressed Length 20238
I have upload 2 pics to my server to show you my problem:

Pic1)
Image

Pic2)
Image

As you can see in the pics the axis values are overlapping. And I have no idea what causes this. I use a sample code from you which draws multiple Y-axis to the chart.
I have enhanced this code so that it alwas calculate the correct width for each y-axis.

This works really fine but if I add the first and the second point to each series I got this problem.

During the PlaceAxis I use the methode you mentioned above : Chart1[Nr].CustomVertAxis.AdjustMaxMin;

As I said bevor ... It works really great after the third point was added.

Can you give me a tipp what causes this problem ?

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

Post by Yeray » Wed Jul 04, 2007 8:44 am

Hi Dominik,

The problem is that for few number of values, axis labels are displayed with 3 decimals and when they display more values, their auto-rescaling makes them to display less decimals.

I suggest you to add an if condition to your code that evaluates the number of points in your series and if there are less than 3, use a higher "extraPos".

I hope it helps.
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 » Wed Jul 04, 2007 8:48 am

Hi Yeray,
I suggest you to add an if condition to your code that evaluates the number of points in your series and if there are less than 3, use a higher "extraPos".
That´s exactly what I did in the meantime:

Code: Select all

      Achsbreite := Achse.MaxLabelsWidth + Achse.TickLength;
      If Achsbreite <= 13 then Achsbreite := 20;
This works ok for me.

Thx for your help !

Post Reply