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

Hide Line chart series

Hi Team,

Could you please help me to hide the line series according to the checkbox value(checked or not), also rebind the legend ?
In addition, I need to disable onclick functionalities(visible/invisible)of chart legend.



Thanks in advance

1 Reply

DD Dharanidharan Dharmasivam Syncfusion Team December 31, 2018 11:02 AM UTC

Hi Jsu, 
 
Greetings from Syncfusion. 
 
We have analyzed your query and prepared a sample. Here we have two series with two check boxes. We have toggled the visibility of the series using the check boxes. And based on your requirement we have disabled the user interaction for toggling the visibility of series using legend by specifying false to ToggleVisibility property of LegendSettings. Find the code snippet below. 
 
 
@(Html.EJS().Chart("LineChart") 
    .LegendSettings(ls=>ls.ToggleVisibility(false)).Render() 
) 
 
 function Series1Visibility(args) { 
        var index = 0; 
        ChartRefresh(index, args.checked); 
    } 
     
  function ChartRefresh(seriesIndex, seriesVisibility) { 
        var chartObj = document.getElementById('LineChart').ej2_instances[0]; 
        chartObj.series[seriesIndex].visible = seriesVisibility; 
        chartObj.refresh(); 
    } 
 
 
This can be changed based on your scenario. 
Screenshot:  

 
 
 
 
Thanks, 
Dharani. 


Loader.
Live Chat Icon For mobile
Up arrow icon