Highlight clicked bar series

2019-09-05 14:36发布

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条回答
爷、活的狠高调
2楼-- · 2019-09-05 15:22

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

查看更多
登录 后发表回答