Page 1 of 1

Problem with 8.03 -> Axis -> MaxLabelsWidth

Posted: Mon Jun 16, 2008 12:47 pm
by 9349911
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.

Posted: Mon Jun 16, 2008 2:15 pm
by narcis
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.

Posted: Tue Jun 17, 2008 5:22 am
by 9349911
Hi Narcis,

thx. Works now as expected :)

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