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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Programmatically check and uncheck the legend's checkbox.

Thread ID:

Created:

Updated:

Platform:

Replies:

132325 Aug 26,2017 09:21 AM UTC Aug 28,2017 11:12 AM UTC WPF 1
loading
Tags: SfChart
Rex
Asked On August 26, 2017 09:21 AM UTC

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.

Durgadevi Selvaraj [Syncfusion]
Replied On 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 




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;