单击恢复x轴值 - NVD3 LineChart [英] Recovering x-axis value on click - NVD3 LineChart

查看:140
本文介绍了单击恢复x轴值 - NVD3 LineChart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在NVD3的 lineChart()中点击事件恢复x轴值?

Is there any way to recover the x axis value on click event in the lineChart() of NVD3?

我得到的最接近的是这个答案: nvd3.js:无法绑定onClick事件与数据点在svg

The closest I get is by this answer: nvd3.js : unable to bind onClick event with the data points in the svg

但我想要的是恢复x轴的值,并重定向到另一个页面,将其作为参数传递。

But what I want is to recover the x axis value and redirect to another page, passing it as parameter.

我也尝试过这种方法,类似于我在multiBarChart上使用,但不成功:

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'
    });
});


推荐答案

页面:

$("g.nv-point-paths").on("hover", function (d) {
    $("g.nv-point-paths path").off("click");
    $("g.nv-point-paths path").on("click", function (d) {
        var xAxisValue = d.currentTarget.__data__.data.point[4].x;
    });
});

如果有人有更好的解决方案,请在这里回答。

If someone have a better solution to this, please answer here.

这篇关于单击恢复x轴值 - NVD3 LineChart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆