【发布时间】:2019-03-18 08:49:03
【问题描述】:
我有 d3 工具提示
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
return '<strong>Value:</strong> <span class="d3-tip-value>' + d.value + '</span>';
});
svg.call(tip);
所以当鼠标悬停在路径上的点时,我在函数(a,b,b)中有更多代码,并且还有无法通过这种方式工作的tip.show方法:
svg.selectAll(".dot")
.data(dataset)
.enter().append("circle")
.attr("class", "dot")
.attr("cx", function(d, i) { return xScale(new Date(d.y.date)) })
.attr("cy", function(d) { return yScale(d.y.value) })
.attr("r", 4)
.on("mouseover", function(a, b, c) {
tip.show; // NOT WORKING
......
但是tip.show 是这样工作的:
svg.selectAll(".dot")
.data(dataset)
.enter().append("circle")
.attr("class", "dot")
.attr("cx", function(d, i) { return xScale(new Date(d.y.date)) })
.attr("cy", function(d) { return yScale(d.y.value) })
.attr("r", 4)
.on("mouseover", tip.show) // WORKING
【问题讨论】:
-
试试
tip.show(a, b, c)。