Legend checkbox select/unselect all
Moderator: Queue Moderators
Legend checkbox select/unselect all
Hi, Is there any option to add select all/ Unselect all checkbox in legend.
-
- Posts: 141
- Joined: Wed Mar 27, 2019 1:05 pm
Re: Legend checkbox select/unselect all
Hello,
Currently there isn't a property that allows this. However, this is still possible to implement via CheckBoxStateChanged -event. First, create a series with no points so it will show up in the LegendBox but not in chart. Then inside the CheckBoxStateChanged -event check if the checkbox of this empty series is clicked. Here is an example:
If you have more than one type of series in the chart, you can use for example var pls in _chart.ViewXY.GetAllLineSeries() inside the foreach statement, which gets all line series types.
Hope this helps.
Best regards,
Lasse
Currently there isn't a property that allows this. However, this is still possible to implement via CheckBoxStateChanged -event. First, create a series with no points so it will show up in the LegendBox but not in chart. Then inside the CheckBoxStateChanged -event check if the checkbox of this empty series is clicked. Here is an example:
Code: Select all
// Creating empty series
FreeformPointLineSeries allSeries = new FreeformPointLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]);
allSeries.Title.Text = "Select all";
allSeries.LineStyle.Color = Colors.Black;
_chart.ViewXY.FreeformPointLineSeries.Add(allSeries);
// Subscribe to the event
_chart.ViewXY.LegendBoxes[0].CheckBoxStateChanged += Legend_CheckBoxStateChanged;
private void Legend_CheckBoxStateChanged(object sender, Arction.Wpf.Charting.Views.CheckBoxStateChangedEventArgs e)
{
_chart.BeginUpdate();
var series = e.Series as FreeformPointLineSeries;
if (series.Title.Text == "Select all") // Check what checkbox was clicked
{
foreach (FreeformPointLineSeries fpls in _chart.ViewXY.FreeformPointLineSeries)
{
fpls.Visible = e.IsChecked;
}
}
_chart.EndUpdate();
}
If you have more than one type of series in the chart, you can use for example var pls in _chart.ViewXY.GetAllLineSeries() inside the foreach statement, which gets all line series types.
Hope this helps.
Best regards,
Lasse