Hide Chart Series by Series Name - Client Side

1 Answer 35 Views
Chart (HTML5)
Jerry
Top achievements
Rank 1
Iron
Iron
Jerry asked on 25 Aug 2021, 01:39 PM

I have figured out how to hide a series by the index but I am not guaranteed the index will always be the same for each series, how can I hide/show series by name client side?

This hides by index:

var chart = $find("<%= myChart.ClientID %>");
var kendoChart = chart.get_kendoWidget();

kendoChart.options.series[1].visible = false;

I have tried to figure out how to get the index from below but have not been successful:

kendoChart.findSeriesByName("mySeriesName");

1 Answer, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 26 Aug 2021, 08:46 AM

Hi Jerry,

You can use the findSeriesByName() method o the chart to access the desired series by name and call its toggleVisiblity() method after that to hide it:

$find("myChart").get_kendoWidget().findSeriesByName("Product 1").toggleVisibility(false);

 

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Chart (HTML5)
Asked by
Jerry
Top achievements
Rank 1
Iron
Iron
Answers by
Vessy
Telerik team
Share this question
or