Page 1 of 1

Working out which series are checked in the legend

Posted: Wed May 10, 2006 3:04 pm
by 9523571
Hi,
I am using the ActiveX version 7.0 and have a chart using checkboxes in the legend.
How can I work out programmatically which series the user has checked or unchecked?

Thanks
Roger

Posted: Thu May 11, 2006 9:50 am
by narcis
Hi Roger,

Yes, you can use TeeChart's OnClickLegend and Legend's Clicked method as shown here:

Code: Select all

Private Sub TChart1_OnClickLegend(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    Dim SeriesIndex As Integer
    
    SeriesIndex = TChart1.Legend.Clicked(X, Y)
    
    If (SeriesIndex <> -1) Then
        TChart1.Header.Text.Clear
        TChart1.Header.Text.Add "Series" & CStr(SeriesIndex + 1) & " Clicked!"
    End If
End Sub

Posted: Thu May 11, 2006 10:12 am
by 9523571
Thanks Narcís,
That could work, but it would be complicated for what I want to do.

When I close a chart, I want to note which series are currently checked and restore that state when I next create that chart. In other words, statically record the current state, rather than dynamically monitoring the changes.

Your suggestion would work - constantly monitoring click events and noting which series they relate to, then updating this through the life of the chart (as series are added and deleted etc.) but it seems complicated for my particular case.

Is there a way of finding out the current status at a point in time?
I was hoping there would be a simple property value for each series or something like that.

Thanks
Roger

Posted: Thu May 11, 2006 10:59 am
by narcis
Hi Roger,

Yes, you should just check which series are visible in the chart using TChart1.Series(i).Active boolean property.

Posted: Thu May 11, 2006 11:01 am
by 9523571
Excellent!

Thanks Narcís.