Checkbox for a series group

TeeChart for ActiveX, COM and ASP
Post Reply
JAV
Newbie
Newbie
Posts: 65
Joined: Thu May 12, 2011 12:00 am

Checkbox for a series group

Post by JAV » Mon May 23, 2011 4:16 pm

It is possible to group several series in a single checkbox under a main serie, so that the checkbox in the main serie will serve to display or hide the whole group while each sub series could be controlled with their own individual checkbox?

For example, the image attached shows four series where T-A6:M1 is the main serie. The idea is that T-A6:M1 checkbox turns on and off the others and, at the same time, P10, p50 and p90 must keep their checkboxes working.
Attachments
example.JPG
example.JPG (62.02 KiB) Viewed 6428 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Checkbox for a series group

Post by Yeray » Tue May 24, 2011 9:54 am

Hello JAV,

You could use OnClickLegend to control how the other series must respond when a concrete area is clicked (the area for the main series item).
Here it is an example:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  
  Dim i As Integer
  For i = 0 To 3
    TChart1.AddSeries scFastLine
    TChart1.Series(i).FillSampleValues
  Next i
  
  TChart1.Series(0).Title = "Main series"
  TChart1.Series(0).Pen.Width = 3
  
  TChart1.Legend.CheckBoxes = True
End Sub

Private Sub TChart1_OnClickLegend(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  If ((X >= TChart1.Legend.Left) And (Y >= TChart1.Legend.Top) And (X <= TChart1.Legend.Left + TChart1.Legend.Width) And (Y <= TChart1.Legend.Top + TChart1.Canvas.FontHeight + 5)) Then
    Dim i As Integer
    For i = 1 To TChart1.SeriesCount - 1
      TChart1.Series(i).Active = TChart1.Series(0).Active
    Next i
  End If
End Sub
This sets the "other series" to be active if the main series is set to active, and sets the "other series" to be hidden if the main series is hidden. If you want to remember the "other series" statuses before they are set to be hidden, you could use variables to do so.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JAV
Newbie
Newbie
Posts: 65
Joined: Thu May 12, 2011 12:00 am

Re: Checkbox for a series group

Post by JAV » Tue May 24, 2011 5:02 pm

Hello Yeray,

Excellent! thank you very much. This solved my problem :D

Best regards,

JAV

Post Reply