Problem with 8.03 -> Axis -> MaxLabelsWidth

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:

Problem with 8.03 -> Axis -> MaxLabelsWidth

Post by moelski » Mon Jun 16, 2008 12:47 pm

Hi !

We discovered a problem with 8.03. Please find the following file in your upload area ...
Received Problem - MaxLabelsWidth.zip Content Type application/x-zip-compressed Length 26320
Compile it with 8.03 and press Create Button -> it hangs.

The problem is MaxLabelsWidth. There is a bug which causes the whole application to hang. Could this be a issue with fix TV52011721 ?

Hopefully you can give me a hint how to fix 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 Jun 16, 2008 2:15 pm

Hi Dominik,

Thanks for the example project. Debugging it I found where the problem is. And yes, it is related to the fix for the bug you mention.

Before retrieving MaxLabelsWidth you need to have the axis drawn so they have a valid Increment, which is used for labels width calculation. So you can solve the problem calling chart's Draw method, for example:

Code: Select all

procedure TForm22.PlaceLVAxis;
const extraPos              = 18 + 4; //12;      + 2 für Text
      minMarginLeft         = 5; //15;
      minMarginRight        = 5; //15;
var   Achse                 : TChartAxis;
      Nr                    : Word;
      NextXLeft, NextXRight : Integer;
      MargLeft, MargRight   : Integer;
      Achsbreite            : Integer;
begin
  NextXLeft := 0; NextXRight := 0;
  MargLeft  := 0; MargRight  := 0;

  for Nr := 0 to MainChart.SeriesCount - 1 do begin
    MainChart[Nr].CustomVertAxis := MainChart.CustomAxes.Items[Nr];
   // MainChart.CustomAxes.Items[Nr].Visible := True;
    MainChart[Nr].CustomVertAxis.Visible := MainChart[Nr].Active;
    MainChart[Nr].CustomVertAxis.AdjustMaxMin;
    MainChart[Nr].CustomVertAxis.Title.Visible := MainChart[Nr].Active;
  end;

  MainChart.Draw;

  for Nr := 0 to MainChart.SeriesCount - 1 do begin
    Achse := MainChart.Series[Nr].GetVertAxis;
    if MainChart[Nr].Active and Assigned(Achse) and Achse.Visible then
    begin
      Achse.StartPosition := 0;
      Achse.EndPosition   := 100;
      // Workaround weil bei den ersten beiden Werten die Achsbreite zu klein ist
      //Achsbreite := 20;
      Achsbreite := Achse.MaxLabelsWidth;
      Achsbreite := Achsbreite + Achse.TickLength; // + Achse.Title.Height;
      If Achsbreite <= 13 then Achsbreite := 20;     //20
      // ENDE : Workaround weil bei den ersten beiden Werten die Achsbreite zu klein ist
      if Achse.OtherSide then     //  ca.OtherSide        Achsen[Nr].Rechts
      begin
        Achse.PositionPercent := NextXRight;
        Achse.OtherSide       := True;
        NextXRight := NextXRight - Achsbreite - extraPos;
        MargRight  := MargRight  + Achsbreite + extraPos;
      end
      else
      begin
        Achse.PositionPercent := NextXLeft;            //0
        NextXLeft := NextXLeft - Achsbreite - extraPos;      // -43
        MargLeft  := MargLeft  + Achsbreite + extraPos;        // 43
      end;
    end;

    MainChart.MarginLeft  := Max(minMarginLeft, MargLeft);
    MainChart.MarginRight := Max(minMarginRight, MargRight);
  end;
end;
Anyway, I'll add this issue to our defect list to be reviewed and enhanced for future releases.
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 » Tue Jun 17, 2008 5:22 am

Hi Narcis,

thx. Works now as expected :)

Btw. When will 8.03 official released? I would like to take a look into the changes ...

Post Reply