We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Programmatically check and uncheck the legend's checkbox.

Is there any way I can set the legends checkbox programmatically? Also I want to know what item in the legend are currently check and uncheck so that when he/she close and open the chart I can save and set the visible series.

1 Reply

DS Durgadevi Selvaraj Syncfusion Team August 28, 2017 08:26 AM UTC

  
Hi Rex, 

Thanks for contacting Syncfusion Support. 

We have analyzed your query (programmatically check and uncheck legend’s check box and know the current checked and unchecked legend) and achieved it by using IsSeriesVisible property in chart series as shown in the below code, 

MainWindow.xaml: 
<chart:SfChart Margin="10"> 
             
            <chart:SfChart.Legend> 
                <chart:ChartLegend CheckBoxVisibility="Visible"/> 
            </chart:SfChart.Legend> 
 
          <chart:LineSeries ItemsSource="{Binding Collection}"  Label="Series1" XBindingPath="XValue" YBindingPath="YValue"/> 
 
            <chart:LineSeries ItemsSource="{Binding Collection}" IsSeriesVisible="False" Label="Series2" XBindingPath="XValue" YBindingPath="YValue1"/> 
 
            <chart:LineSeries ItemsSource="{Binding Collection}" Label="Series3" XBindingPath="XValue" YBindingPath="YValue2"/> 
        </chart:SfChart> 


Please find the output screenshot, 
 
We have prepared a simple sample for your reference and please downloaded from the below link, 
You can refer our UG Documentation link to know more about Legend in SfChart, 


Regards,  
Durgadevi S 




Loader.
Live Chat Icon For mobile
Up arrow icon