Working out which series are checked in the legend

TeeChart for ActiveX, COM and ASP
Post Reply
Roger Nye
Newbie
Newbie
Posts: 10
Joined: Tue Aug 17, 2004 4:00 am

Working out which series are checked in the legend

Post by Roger Nye » Wed May 10, 2006 3:04 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 11, 2006 9:50 am

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
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Roger Nye
Newbie
Newbie
Posts: 10
Joined: Tue Aug 17, 2004 4:00 am

Post by Roger Nye » Thu May 11, 2006 10:12 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 11, 2006 10:59 am

Hi Roger,

Yes, you should just check which series are visible in the chart using TChart1.Series(i).Active boolean property.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Roger Nye
Newbie
Newbie
Posts: 10
Joined: Tue Aug 17, 2004 4:00 am

Post by Roger Nye » Thu May 11, 2006 11:01 am

Excellent!

Thanks Narcís.

Post Reply