我在定位工具提示点时遇到问题。我正在使用序数 X 标度,但我无法让它工作......不确定我是否必须更改我的数据结构或......任何见解将不胜感激。我在下面包含了一个 JS FIDDLE 链接
tooltip_container.selectAll("dot")
.data(dataset)
.enter().append("circle")
.attr("r", 5)
.attr("cx", function(d,i) { /* return x(d) ?? */})
.attr("cy", function(d,i) { /* return y(d) ?? */})
最佳答案
如果你想为你需要的所有行创建工具提示
tooltip_container.selectAll("dot")
.data(dataset)
.enter().append("circle")
.attr("r", 5)
.attr("cx", function(d,i) { return x(d.month) })
.attr("cy", function(d,i) { return y(d.undecided) })
tooltip_container.selectAll("dot")
.data(dataset)
.enter().append("circle")
.attr("r", 5)
.attr("cx", function(d,i) { return x(d.month) })
.attr("cy", function(d,i) { return y(d.yes) })
tooltip_container.selectAll("dot")
.data(dataset)
.enter().append("circle")
.attr("r", 5)
.attr("cx", function(d,i) { return x(d.month) })
.attr("cy", function(d,i) { return y(d.no) })
关于javascript - D3.js 折线图 - 定位点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32023211/