我使用d3.js编写了此代码。
这是我的问题:
当您将鼠标悬停在矩形上时,会出现弹出工具提示,但不会在指针位于矩形内的文本上方时显示。
当鼠标悬停在文本上以及形状的其他部分时,我希望显示工具提示。如何实现这一目标?
这是我的矩形代码:
cartridgeRectangles.push({"x_axis":startx+2, "y_axis":90+textbeginy, "width":35, "height":15, "color":discovery_status_color, "stroke":"#33CC33", "thickness":1, "mover":chassisDetails , "movercolor":"darkgreen", "mout":"True", "moutcolor":"#33CC33" });
答案 0 :(得分:2)
问题是文本正在捕获鼠标。这可以通过删除css中的文本的指针事件来避免:
// This will apply to all text elements, consider using a class
text {
pointer-events: none;
}
指针事件中的更多信息:https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events