【问题标题】:dc lineChart pop up datapoint info on clickdc lineChart 点击时弹出数据点信息
【发布时间】:2017-02-10 00:41:42
【问题描述】:

我正在尝试检测对折线图数据点的点击。

根据这个答案( dc scatter plot binding onClick event )我正在尝试按照描述使用预转换事件,但我必须遗漏一些东西。

lineChart.on('pretransition', function() {
    lineChart.selectAll('path.symbol').on('click', function(d) {
         alert('value: ' + d);
         //How would I pop-up the datapoint values?
    });
});

jsFiddle example

【问题讨论】:

    标签: javascript d3.js dc.js


    【解决方案1】:

    每个图表都为其图表使用不同的元素和类。这目前没有记录,所以最好的办法是去源头。

    在这种情况下,下面是一行:

    var dots = g.selectAll('circle.' + DOT_CIRCLE_CLASS)
    

    https://github.com/dc-js/dc.js/blob/f7e0a47d1246b95acbc279f14243524a0769fb84/src/line-chart.js#L279

    查找常量后,您要查找的选择器应该是circle.dot

    我添加了一个问题来记录这些内容。

    https://github.com/dc-js/dc.js/issues/1278

    【讨论】:

    • 谢谢 - 显而易见的应该是,但并非总是如此。 (至少对我来说。)
    • 嗨,Gordon,this is a (new) related question,如果你有时间看看。
    猜你喜欢
    • 1970-01-01
    • 2019-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多