D3.js D3工具提示未显示
我在更改工具提示所针对的元素的颜色时显示工具提示时遇到问题。我可以注释掉工具提示代码,元素的笔划颜色也会改变,但是我需要同时修改工具提示和类。非常感谢您的帮助。以下是我所说的:D3.js D3工具提示未显示,d3.js,D3.js,我在更改工具提示所针对的元素的颜色时显示工具提示时遇到问题。我可以注释掉工具提示代码,元素的笔划颜色也会改变,但是我需要同时修改工具提示和类。非常感谢您的帮助。以下是我所说的: var svg = d3.select("#app_dataPlane") .append("svg") .attr("width", width) .attr("height", height); var tip = d3.tip()
var svg = d3.select("#app_dataPlane")
.append("svg")
.attr("width", width)
.attr("height", height);
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function (d) {
return "<strong>DPID:</strong> <span style='color:red'>" + d.name + "</span><br />" + "<strong>State:</strong> <span style='color:red'>" + d.state + "</span>";
})
svg.call(tip);
var link = svg.selectAll(".link")
.data(topoObj.links)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", 2)
.on("mouseover", function (d) {
d3.selectAll(".link").classed("selectedLink", false);
d3.select(this).classed("selectedLink", true);
d3.select("#app_srcSwitch").html(d.source.name);
d3.select("#app_destSwitch").html(d.target.name);
});
var node = svg.selectAll(".switch")
.data(topoObj.nodes)
.enter()
.append("circle")
.attr("r", 6)
.attr("stroke", "white")
.attr("class","switch")
.attr("fill", function (d) {
if (d.group == 1) {
return "#15a9ff";
} else if (d.group == 2) {
return "#f98802";
} else if (d.group == 3) {
return "#ca5eff";
} else if (d.group == 4) {
return "#37a302";
} else if (d.group == 5) {
return "#00a4b0";
} else if (d.group == 6) {
return "#ff6054";
} else if (d.group == 7) {
return "#7b75ff";
} else if (d.group == 8) {
return "#b77264";
} else {
return "#8c8c8c";
}
})
.on('mouseover', function (d) {
d3.selectAll(".switch").classed("selectedSwitch", false);
d3.select(this).classed("selectedSwitch", true);
d3.select("#app_stateInfo").html(d.state);
d3.select("#app_dpidInfo").html(d.name);
d3.select("#app_InstanceInfo").html(d.onosInstance);
})
.on('mouseover', tip.show)
.on('mouseout', tip.hide)
.call(force.drag);
var svg=d3.选择(“应用程序数据平面”)
.append(“svg”)
.attr(“宽度”,宽度)
.attr(“高度”,高度);
var tip=d3.tip()
.attr('class','d3 tip')
.偏移量([-10,0])
.html(函数(d){
返回“DPID:”+d.name+”
“+”状态:“+d.State+”;
})
svg.call(tip);
var link=svg.selectAll(“.link”)
.数据(拓扑对象链接)
.enter().append(“行”)
.attr(“类”、“链接”)
.样式(“笔划宽度”,2)
.on(“鼠标悬停”,功能(d){
d3.selectAll(“.link”).classed(“selectedLink”,false);
d3.选择(this).classed(“selectedLink”,true);
d3.选择(“#app#srcSwitch”).html(d.source.name);
d3.选择(“#app#destSwitch”).html(d.target.name);
});
var node=svg.selectAll(“.switch”)
.数据(拓扑对象节点)
.输入()
.附加(“圆圈”)
.attr(“r”,6)
.attr(“笔划”、“白色”)
.attr(“类”、“开关”)
.attr(“填充”,功能(d){
如果(d.group==1){
返回“#15a9ff”;
}else如果(d.group==2){
返回“#f98802”;
}else如果(d.group==3){
返回“#ca5eff”;
}else如果(d.group==4){
返回“#37a302”;
}else如果(d.group==5){
返回“#00a4b0”;
}else如果(d.group==6){
返回“#ff6054”;
}else如果(d.group==7){
返回“#7b75ff”;
}else如果(d.group==8){
返回“#b77264”;
}否则{
返回“#8c8c”;
}
})
.on('mouseover',函数(d){
d3.selectAll(“开关”).classed(“selectedSwitch”,false);
d3.选择(this).classed(“selectedSwitch”,true);
d3.选择(“#app#u stateInfo”).html(d.state);
d3.选择(“#app#dpidInfo”).html(d.name);
d3.选择(“#app#u InstanceInfo”).html(d.onosInstance);
})
.on('mouseover',tip.show)
.on('mouseout',tip.hide)
.呼叫(强制拖动);
对.on(“mouseover”,…)
的后续调用将覆盖先前在那里设置的内容。要组合几件事情,请在处理程序函数中执行它们:
.on('mouseover', function (d) {
d3.selectAll(".switch").classed("selectedSwitch", false);
d3.select(this).classed("selectedSwitch", true);
d3.select("#app_stateInfo").html(d.state);
d3.select("#app_dpidInfo").html(d.name);
d3.select("#app_InstanceInfo").html(d.onosInstance);
tip.show();
});
对
.on(“mouseover”,…)
的后续调用将覆盖先前在那里设置的内容。要组合几件事情,请在处理程序函数中执行它们:
.on('mouseover', function (d) {
d3.selectAll(".switch").classed("selectedSwitch", false);
d3.select(this).classed("selectedSwitch", true);
d3.select("#app_stateInfo").html(d.state);
d3.select("#app_dpidInfo").html(d.name);
d3.select("#app_InstanceInfo").html(d.onosInstance);
tip.show();
});
对
.on(“mouseover”,…)
的后续调用将覆盖先前在那里设置的内容。要组合几件事情,请在处理程序函数中执行它们:
.on('mouseover', function (d) {
d3.selectAll(".switch").classed("selectedSwitch", false);
d3.select(this).classed("selectedSwitch", true);
d3.select("#app_stateInfo").html(d.state);
d3.select("#app_dpidInfo").html(d.name);
d3.select("#app_InstanceInfo").html(d.onosInstance);
tip.show();
});
对
.on(“mouseover”,…)
的后续调用将覆盖先前在那里设置的内容。要组合几件事情,请在处理程序函数中执行它们:
.on('mouseover', function (d) {
d3.selectAll(".switch").classed("selectedSwitch", false);
d3.select(this).classed("selectedSwitch", true);
d3.select("#app_stateInfo").html(d.state);
d3.select("#app_dpidInfo").html(d.name);
d3.select("#app_InstanceInfo").html(d.onosInstance);
tip.show();
});
我让那条路变得更难了。哈哈。谢谢你,这很有效。我让这条路变得更难了。哈哈。谢谢你,这很有效。我让这条路变得更难了。哈哈。谢谢你,这很有效。我让这条路变得更难了。哈哈,谢谢你,这很有效。