Page 1 of 1

Legend click

Posted: Fri Aug 25, 2006 1:38 pm
by 6925851
i have to execute somefunction when user click on the legend (each series)

i am not using teelistbox1

is there any event available to know where the user is clicked on the legend ....?


if i use the teelistbox then can linked to the chart legend , so that only tee listbox appears and when user changes the legend alignment ...? can teelistbox also changes

pls advise me
aravind

Posted: Fri Aug 25, 2006 2:36 pm
by narcis
Hi Aravind,

Yes, you can do it using OnClickLegend event and using legend's Clicked method as shown here:

Code: Select all

Private Sub Form_Load()
    For i = 0 To TChart1.SeriesCount - 1
        TChart1.Series(i).FillSampleValues 10
        TChart1.Series(i).Color = vbBlue
    Next
End Sub

Private Sub TChart1_OnClickLegend(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    Index = TChart1.Legend.Clicked(X, Y)
    
    If (Index <> -1) Then
        For i = 0 To TChart1.SeriesCount - 1
            If (i = Index) Then
                TChart1.Series(i).Color = vbRed
            Else
                TChart1.Series(i).Color = vbBlue
            End If
        Next
    End If
End Sub