Is there any way to recover the x axis value on click event in the lineChart()
of NVD3?
The closest I get is by this answer: nvd3.js : unable to bind onClick event with the data points in the svg
But what I want is to recover the x axis value and redirect to another page, passing it as parameter.
I tried this approach too, similar as one that I use on multiBarChart, but unsuccessful:
$("g.nv-point-paths").on("hover", function (d) {
$("path").off("click");
$("path").on("click", function (d) {
//do something with 'd'
});
});
I discovered it by myself, by debugging the javascript of the page:
If someone have a better solution to this, please answer here.
I have been using the following:
The
e
variable has everything you need inside of it. Just set a breakpoint and inspect thee
var to see how to access whatever you want.Example: