LegendBox Programmatically Select/Deselect Series

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
giryhepai
Posts: 6
Joined: Thu May 16, 2019 9:43 am

LegendBox Programmatically Select/Deselect Series

Post by giryhepai » Mon May 20, 2019 2:04 pm

Hi all,

Is there any way I can programmatically Select/Deselect a series in the LegendBox?

For example:
Series1 - Checked
Series2 - Checked
HiddenSeriesByDefault - Unchecked

Best regards,
giryhepai

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: LegendBox Programmatically Select/Deselect Series

Post by Arction_LasseP » Tue May 21, 2019 8:12 am

Hello,

Currently there is no property such as LegendBoxes[0].series.checked. The only exception is CheckBoxStateChanged -event, which has e.IsChecked -property, which tells the state of the clicked checkbox. This event, when subscribed to, triggers only when a checkbox in a legend box is clicked so it probably is not very useful in this case.

However, since having a series checked in the legend box basically means that the respective series should be visible in the chart, this kind of behaviour can be achieved by setting visibility of the series true/false. If freeformPointLineSeries.Visible is set true, the respective checkbox in the legend box should automatically be checked. Similarly, Visible = false means that the checkbox is not checked. Here is a simple example, in which all FreeformPointLineSeries are set not visible (unchecked in legend box) when a chart is double-clicked:

Code: Select all

_chart.MouseDoubleClick += _chart_MouseDoubleClick;

private void _chart_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            foreach (FreeformPointLineSeries fp in _chart.ViewXY.FreeformPointLineSeries)
            {
                fp.Visible = false;
            }           
        }
This behaviour is not limited to FreeformPointLineSeries only, as all the other series work the same way as well.

Hope this is helpful.

giryhepai
Posts: 6
Joined: Thu May 16, 2019 9:43 am

Re: LegendBox Programmatically Select/Deselect Series

Post by giryhepai » Tue May 21, 2019 2:47 pm

I like the idea you're presenting, although it doesn't actually help me.

Thanks for the suggestions,
giryhepai

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: LegendBox Programmatically Select/Deselect Series

Post by ArctionKestutis » Fri May 24, 2019 2:09 pm

Actually Series.Visible property and LegendBox checkbox are tightly bind.
If you disable Series.Visible property it will clear corresponding item checkbox. And if you click the checkbox in Legend, this will modifies Series.Visible property.
I believe this is that you need.

Hope this helps.

Post Reply