Highlight clicked bar series

2019-09-05 15:01发布

问题:

Is there any built in method in kendo when user clicks on the bar chart item, then it will highlight all corresponding items?

For example in the following fiddle, there are five items. If I click item1 in the first bar (1970), it should highlight item1 in second bar (1975).

series: [{
   type: "column",
   field: "value",
   stack: true,
   name: "#= group.value #"
}],

回答1:

You can add the seriesClick event. Then determine which series was clicked and use the toggleHighlight() method to turn off highlighting on all other series and turn it on for the clicked one:

seriesClick: function(e) {
    var clickedSeries = e.series.name;
    var chart = $("#chart").data("kendoChart");
    for (var i=0; i< chart.options.series.length; i++){
        chart.toggleHighlight(false, chart.options.series[i].name);
    }
    chart.toggleHighlight(true, clickedSeries);
}

Updated FIDDLE