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.

Click anywhere on chart, not just data items

See original GitHub issue

I’m trying to implement a feature where the user can click anywhere on the chart to add kind of annotations, however C3 only recognises click events on data points. Setting data.selection.grouped = true as suggested elsewhere makes it partly work, however the onclick event callback is then called once per data item, and still only works for the data items themselves.

What i’m after is a way of recognising a click anywhere, so I am then able to calculate what the X value should be based on the x-axis’ scale and use it elsewhere. Is there any way I can do this?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pareeohnoscommented, Nov 15, 2014

Ah so it does! Initially this wasn’t working as I expected, calling chart.internal.x(xCoord) returned -2031062 but calling chart.internal.x.invert(xCoord) instead works as expected 😃 Thanks for all the help

0reactions
Hypersapiencommented, Jan 23, 2019

I’m using this method on a Stacked Area Graph, and I got it working. I can tell which X-axis value is being clicked on, but I don’t know how to tell which vertical area of the graph is being clicked on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Click event of stacked line chart not working
On click of chart, the chart method getElementsAtEvent() is returning empty array. On the click event function, I need the x-axis data points....
Read more >
Change the data series in a chart - Microsoft Support
Right-click your chart, and then choose Select Data. Select Data Source dialog box. In the Legend Entries (Series) box, click the series you...
Read more >
Interactions - Chart.js
For example, to have the chart only respond to click events, you could do: ... data: data, options: { // This chart will...
Read more >
Charts as the source of actions—ArcGIS Dashboards
Clicking anywhere that does not represent a data point on a chart clears the selection. When a chart is showing continuous categories, such...
Read more >
Event handlers in JavaScript - Plotly
Unlike plotly_click , a plotly_doubleclick is registered upon clicking anywhere on the graph (not just data points), therefore, plotly_doubleclick does not ...
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