我使用d3js创建了一个气泡图,并在其中添加了Extjs工具提示。在此过程中,我为气泡图中的每个圆圈创建了单独的工具提示。当我将鼠标指针从1圈移到另一圈时,工具提示的显示出现明显的延迟。所以我想为所有的圆圈提供一个工具提示。
有人能告诉我如何使用delegate: '.x-form-field-wrap'创建单个工具提示吗?
这是小提琴。
发布于 2015-11-16 12:49:41
没有必要创建多个工具提示。创建一个单独的工具提示,只需更新它在鼠标覆盖和mousemove上的位置。
var tip = Ext.create('Ext.tip.ToolTip',{
title: 'test',
width: 150,
height: 40,
radius:5,
hidden: true,
anchor: 'left',
autoHide: false,
trackMouse: true,
anchorToTarget: false
});
circle.on('mouseover',function(d,i){
tip.setTitle("radius: "+d.radius);
tip.showAt([d3.event.x,d3.event.y]);
}).on('mousemove',function(d,i){
tip.setTitle("radius: "+d.radius);
tip.showAt([d3.event.x,d3.event.y]);
});更新的小提琴
发布于 2015-11-16 12:09:28
这个问题是xy问题的一个典型例子。
您可以在一行中解决问题,即在工具提示上设置showDelay:0。
发布于 2015-11-16 12:59:07
您需要计算X和Y坐标,并在mouseover事件上显示一个div。您可以使用下面的小提琴代码来完成此操作:
我认为这个解决方案比extjs更好。
var circle = svg.selectAll("circle")
.data(nodes)
.enter().append("circle")
.attr("r", function (d) {
return d.radius;})
.style("fill", function (d, i) {
return "green";}).on("mouseover", function (d, i) {
tDiv.html("Radius :" + d.radius + "</br>Name:" + data.children[i].name + "</br>Size:" + data.children[i].size);
tDiv.style("left", ((d3.event.pageX) - $(tDiv[0]).width() - 10) + "px").style("top", (d3.event.pageY - 0) + "px"); }).on("mouseleave", function (d, i) {
tDiv.style("display", "none");})
.call(drag);您可以参考这个小提琴密码
https://stackoverflow.com/questions/33731978
复制相似问题