10
使用D3更新SVG元素Z-索引
使用D3库将SVG元素置于z顺序顶部的有效方法是什么? 我的特定情况是一个饼图其中突出(通过添加stroke到path)当鼠标在给定的片。生成我的图表的代码块如下: svg.selectAll("path") .data(d) .enter().append("path") .attr("d", arc) .attr("class", "arc") .attr("fill", function(d) { return color(d.name); }) .attr("stroke", "#fff") .attr("stroke-width", 0) .on("mouseover", function(d) { d3.select(this) .attr("stroke-width", 2) .classed("top", true); //.style("z-index", 1); }) .on("mouseout", function(d) { d3.select(this) .attr("stroke-width", 0) .classed("top", false); //.style("z-index", -1); }); 我尝试了几种方法,但到目前为止还没有运气。同时使用style("z-index")和调用classed均无效。 在我的CSS中,“ top”类的定义如下: .top { fill: red; z-index: 100; …
81
javascript
svg
d3.js