[Bug] Changing LegendItem text breaks redraw
Posted: Thu Mar 12, 2009 1:18 am
Add this code:
Click a series, then resize the form. The legend text is detached and floats around.
Code: Select all
Option Explicit
Private Sub Form_Load()
TChart1.AddSeries scLine
TChart1.AddSeries scLine
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues 10
TChart1.Series(0).Title = "Series No. 001"
TChart1.Series(1).FillSampleValues 10
TChart1.Series(1).Title = "Series No. 002"
TChart1.Series(2).FillSampleValues 10
TChart1.Series(2).Title = "Series No. 003"
End Sub
Private Sub Form_Resize()
TChart1.Top = 0
TChart1.Left = 0
TChart1.Width = Me.Width
TChart1.Height = Me.Height - 1000
End Sub
Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim nLegCount As Integer, i As Integer
Dim sItemText As String, sSeriesName As String
Dim li As TeeChart.ILegendItem
nLegCount = TChart1.Legend.LastValue
sSeriesName = TChart1.Series(SeriesIndex).Title
For i = 0 To nLegCount
Set li = TChart1.Legend.Item(i)
sItemText = li.Text
If (Right(sItemText, 1) = "*") Then
sItemText = Left(sItemText, Len(sItemText) - 1)
End If
If (sItemText = sSeriesName) Then
li.Text = sItemText & "*"
Else
li.Text = sItemText
End If
Next i
End Sub