【发布时间】:2020-10-14 19:33:23
【问题描述】:
我的目标是改变特定路径的不透明度。
这是我为图表中的每个切片添加路径的地方:
h = f.selectAll("path").data(o);
h.enter().append("path")
.attr("id", function (t, n) { return "path-" + n})
.attr("d", x).attr("fill-rule", "evenodd").style("fill", n).on("click", l)
.on("mouseover", function(t,n) {mouseover("path-" + n)});
鼠标悬停功能内部是我尝试过的:
function mouseover(d){
// d is the id of the path that was hovered over
// d looks like 'path-20'
d3.selectAll("path").style("opacity", 0.3); // changes opacity for entire sunburst chart
d3.selectAll(d).style("opacity", 0.3); // does nothing
d3.selectAll("path-20").style("opacity", 0.3); // does nothing
d3.select(d).style("opacity", 0.3); // does nothing
d3.select("path-20").style("opacity", 0.3); // does nothing
}
【问题讨论】: