我使用这个bl.ocks.org代码示例创建了一个多系列折线图.我已经设法在JSFiddle上重新创建它.
现在,我正在尝试添加一个x值鼠标悬停工具提示,当您悬停其垂直位置时,它会显示每行的工具提示.事情是这样的,但对于多行.
我发现这个StackOverflow答案(它包括一个JSFiddle),但我似乎无法使它与我的多重系列折线图一起工作.
svg.append("path") // this is the black vertical line to follow mouse
.attr("class","mouseLine")
.style("stroke","black")
.style("stroke-width", "1px")
.style("opacity", "0");
var mouseCircle = causation.append("g") // for each line, add group to hold text and circle
.attr("class","mouseCircle");
mouseCircle.append("circle") // add a circle to follow along path
.attr("r", 7)
.style("stroke", function(d) { console.log(d); return color(d.key); })
.style("fill","none")
.style("stroke-width", "1px");
mouseCircle.append("text")
.attr("transform", "translate(10,3)"); // text to hold coordinates
var bisect = d3.bisector(function(d) { …Run Code Online (Sandbox Code Playgroud)