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

How chart default series hidden and legend click series visible

Hello,

I would like to default series hidden and legend click series visible.

I tried the code below with the visibility which works on the series but legend click series is not visible.

  1.                 function onlegenditemclick(sender) 
  2. {
  3.    for (var i = 0; i < sender.model.series.length; i++) {
  4.        if (sender.model.series[i].name == "Wastage")
  5.            sender.model.series[i].visibility = "visible";
  6.    }
  7. }

  8. function onclientPreRender(sender) {
  9.    for (var i = 0; i < sender.model.series.length; i++) {
  10.        if (sender.model.series[i].name == "Wastage")
  11.            sender.model.series[i].visibility = "hidden";
  12.    }
  13. }

Attachment: column_e5da3463.zip

3 Replies

SK Sanjith Kesavan Syncfusion Team November 17, 2015 06:24 AM UTC

Hi jinchul oh,
Thanks for contacting Syncfusion support. The “preRender” event will trigger whenever the chart is redrawn, the legend click event will redraw the chart so the preRender will trigger again. In your sample we found that you have set the series visibility as "hidden" in the preRender event and in the legendItemClick event you have set the visibility of the series as "visible" and thus the issue. To avoid this please set the series visibility as "hidden" directly while creating a series.

For setting the series visibility as hidden please use the following code example [JS]
name: 'Wastage',
fill: "#34495E",
opacity: 0.7,
visibility: "hidden"
In the above code example we have set the visibility of the series as hidden. So when the chart is rendered particular series is hidden. Please find the below screenshot

If the legend is clicked then the chart is visible. Please find the below screenshot.

We have modified your sample as per you requirement. Please find the sample from below location.
Sample Link: http://www.syncfusion.com/downloads/support/forum/121160/ze/column-970290589

Please let us know if you have any concern.

Thanks,
Sanjith K.


RM Rajasekaran Mani September 23, 2016 10:25 AM UTC

We would like to explore same behavior in Xamarin forms doughnut chart. Please provide your inputs on that.


YP Yuvaraj Palanisamy Syncfusion Team September 26, 2016 07:37 PM UTC

Hi Rajasekaran Mani, 
 
We have prepared a workaround sample as per your requirement. Please find the sample from the below location. 
 
  
Regards, 
Yuvaraj  


Loader.
Live Chat Icon For mobile
Up arrow icon