Legend checkbox select/unselect all

A forum dedicated to WPF version of LightningChart Ultimate.

Legend checkbox select/unselect all

Postby sri » Wed Jul 31, 2019 7:57 pm

Hi, Is there any option to add select all/ Unselect all checkbox in legend.
sri
 
Posts: 3
Joined: Wed Jul 31, 2019 6:44 pm

Re: Legend checkbox select/unselect all

Postby Arction_LasseP » Thu Aug 01, 2019 6:59 am

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:

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
Arction_LasseP
 
Posts: 39
Joined: Wed Mar 27, 2019 1:05 pm


Return to LightningChart Ultimate WPF

Who is online

Users browsing this forum: Google [Bot] and 9 guests

cron