IAxisLabels.Width & IAxisLabels.MaxWidth

TeeChart for ActiveX, COM and ASP
Post Reply
FP
Newbie
Newbie
Posts: 14
Joined: Mon May 17, 2004 4:00 am

IAxisLabels.Width & IAxisLabels.MaxWidth

Post by FP » Mon Jun 07, 2004 4:12 pm

Hi,

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

/ Fredrik

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Jun 09, 2004 10:39 am

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

Post Reply