Page 1 of 1
Checkbox for a series group
Posted: Mon May 23, 2011 4:16 pm
by 15059326
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.
Re: Checkbox for a series group
Posted: Tue May 24, 2011 9:54 am
by yeray
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.
Re: Checkbox for a series group
Posted: Tue May 24, 2011 5:02 pm
by 15059326
Hello Yeray,
Excellent! thank you very much. This solved my problem
Best regards,
JAV