How to add onclick event for each node of scatter chart of NVD3. see the example
Please help.
How to add onclick event for each node of scatter chart of NVD3. see the example
Please help.
I prefer Using D3 Dispatch Event
chart.scatter.dispatch.on("elementClick", function(e) {
console.log(e);
});
API Documents Are Getting Better NVD3 API
I am not sure if there is a direct way to accomplish this using NVD3
, but I had a similar issue before.
I used the d3.selectAll()
, add this code once after the chart is loaded.
d3.selectAll("#chart svg path").on('click', function (e) {
console.log(e); // Do your stuff here
});
Returns an object like the following when you click on a point
Object {data: Array[4], series: 3, point: 27}
Hope it helps