dc lineChart弹出数据点信息点击 [英] dc lineChart pop up datapoint info on click
问题描述
我试图检测点击线图数据点。
I am attempting to detect click on line chart datapoints.
根据此回答( dc散点图绑定onClick事件 )我试图使用前面描述的预转换事件,但我必须缺少一些东西。
Per this answer ( dc scatter plot binding onClick event ) I am attempting to use the pretransition event as described, but I must be missing something.
lineChart.on('pretransition', function() {
lineChart.selectAll('path.symbol').on('click', function(d) {
alert('value: ' + d);
//How would I pop-up the datapoint values?
});
});
推荐答案
每个图表使用不同的元素和类其图。
Each chart uses different elements and classes for its diagrams. This is currently not documented, so the best bet is to go to the source.
在这种情况下,这里是这行:
In this case, here's the line:
var dots = g.selectAll('circle.' + DOT_CIRCLE_CLASS)
https ://github.com/dc-js/dc.js/blob/f7e0a47d1246b95acbc279f14243524a0769fb84/src/line-chart.js#L279
查找后常数,您要查找的选择器应为 circle.dot
After looking up the constant, the selector you're looking for should be circle.dot
我添加了一个问题记录这些。
I've added an issue to document these.
https://github.com/dc-js/dc.js/issues/1278
这篇关于dc lineChart弹出数据点信息点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!