您好基于GerHobbelt/3071239我尝试在链接上添加鼠标悬停事件以显示它的值,所以我第一次尝试更改笔触颜色和宽度,如下所示:
hlink.exit().remove();
hlink.enter().append("path")
.attr("class", "hlink")
.on("mouseover", function() { d3.select(this).style("stroke", "#555555").attr("stroke-opacity", "1.0").attr("stroke-width","4");})
.on("mouseout", function() { d3.select(this).style("stroke", "#ccc").attr("stroke-opacity", "1.0").attr("stroke-width","1") });
但它不能解决任何可以解决它的问题吗? 谢谢
答案 0 :(得分:0)
"冲程"是属性而不是样式,因此请使用.attr()
方法而不是.style()
方法:
hlink.exit().remove();
hlink.enter().append("path")
.attr("class", "hlink")
.on("mouseover", function() { d3.select(this).attr("stroke", "#555555").attr("stroke-opacity", "1.0").attr("stroke-width","4");})
.on("mouseout", function() { d3.select(this).attr("stroke", "#ccc").attr("stroke-opacity", "1.0").attr("stroke-width","1") });