Handling click events on chart grid columns
See original GitHub issue问题简述 (One-line summary)
Is there any way to capture click events on chart columns? My goal is to create a chart with possibility to select individual columns by clicking on them.
版本及环境 (Version & Environment)
- ECharts 版本 (ECharts version): 3.1.3
- 浏览器类型和版本 (Browser version): Google Chrome 49.0.2623.110
- 操作系统类型和版本 (OS Version): Windows 8
期望结果 (Expected behaviour)
I would expect that chart.on('click', () => { console.log('click'); });
captures click events on the entire chart. Or at least i would expect an option like grid: { clickable: true }
.
可能哪里有问题 (What went wrong)
chart.on('click', () => { console.log('click'); });
registers event only on chart components such as bars etc.
ECharts配置项 (ECharts option)
option = {
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (2 by maintainers)
Top Results From Across the Web
I'm trying to add a click event, using javascript, to each column ...
You can create a click handler that retrieves the x and y values from the chart. Then, using that data, you could send...
Read more >Handling Events | Charts - Google Developers
Overview. Google charts can fire events that you can listen for. Events can be triggered by user actions, such as when a user...
Read more >JavaScript Data Grid: Grid Events - AG Grid
You register callbacks for these events through the GridOptions interface. ... e.g. Column Moving, Column Resizing, Range Selection, Fill Handle, etc.
Read more >Data plot click mouse event - FusionCharts
Click on a column plot to trigger data plot click event.
Read more >click - Sets Click Event Handler for Data Series - CanvasJS.com
click : Function · var chart = new CanvasJS.Chart("container", · { ·. ·. · data: [{ · click: function(e){ · alert( e.dataSeries.type+ ",...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have you tried with:
const zr = chart.getZr(); zr.on('click', (params) => { console.log(params); });
You can take extract coordinates from params and get dataIndex with chart.convertFromPixel.
I have used it in my project and I had found an example that used getZr() but I can’t find it again now!
EDIT: I have found the example: https://echarts.apache.org/examples/en/editor.html?c=line-pen
https://echarts.apache.org/api.html#events.Mouse events.click