Page 1 of 1

IAxisLabels.Width & IAxisLabels.MaxWidth

Posted: Mon Jun 07, 2004 4:12 pm
by 9082517
Hi,

IAxisLabels.Width & IAxisLabels.MaxWidth doesn't seem to return correct values when the labels are overridden with the OnGetAxisLabel event.

/ Fredrik

Posted: Wed Jun 09, 2004 10:39 am
by Pep
Hi Fredrik,

yes, you're correct , it's a bug/missing feature. I've added it on our defect/wish list to be considered for the next maintenance releases.
In meantime you can calculate it manually as in the following example :

Code: Select all

Dim LWidth, MaxWidth As Integer
Private Sub Command1_Click()
  MsgBox MaxWidth
End Sub

Private Sub Form_Load()
With TChart1
    .Aspect.View3D = False
    .AddSeries scLine
    .Series(0).AddXY 0, 10, "aa", clTeeColor
    .Series(0).AddXY 1, 13, "bb", clTeeColor
    .Series(0).AddXY 2, 12, "cc", clTeeColor
    .Series(0).AddXY 3, 3, "dd", clTeeColor
    .Series(0).AddXY 4, 11, "ee", clTeeColor
    LWidth = 0
    MaxWidth = 0
End With
End Sub

Private Sub TChart1_OnGetAxisLabel(ByVal Axis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
If Axis = 3 Then
  If ValueIndex = 1 Then
    LabelText = "Custom"
  Else
    LabelText = LabelText
  End If
  LWidth = TChart1.Canvas.TextWidth(LabelText)
  If LWidth > MaxWidth Then
    MaxWidth = LWidth
  End If
End If
End Sub