首页 > 解决方案 > Callbacks on echarts bar graph (e.g. onClick)

问题描述

I'm trying to use echarts in one of my project and haven't worked with echarts before. I've found quit good examples to start with but I want to achieve some additional functionality on bar charts like some callbacks on clicking on individual bars. I'm able to see formatter function for tool-tip here but couldn't find click event. Also, is there any event for clicking on labels on x-axis ? I've checked documentation for echarts here and found callback events but couldn't find a way to get them working for bar charts. Any help/suggestion or am I missing something here ?

标签: javascriptbar-chartecharts

解决方案


这有效:

var myChart = echarts.init(document.getElementById('main'));

myChart.on("click", function (event) {    
    console.log(event);
});

'click' 事件仅在单击栏时触发。


推荐阅读