question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 7 years ago
  • Comments:21 (2 by maintainers)

github_iconTop GitHub Comments

27reactions
OlmoBarberiscommented, Sep 9, 2019

But when I click between two columns, I can not receive any event. I wish I can get the dataIndex where the blue line located. Any idea? @coretez

image

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found