2013-04-08 86 views
2

我在SVG绘制箭头,使用svg:line元素与定义标记如下:D3转换标记

svg_.append("svg:defs") 
     .append("svg:marker") 
     .attr("id", "bluearrowhead") 
     .attr("viewBox", "0 -5 10 10") 
     .attr("refX", 0) 
     .attr("refY", 0) 
     .attr("markerWidth", 6) 
     .attr("markerHeight", 6) 
     .attr("orient", "auto") 
     .append("svg:path") 
     .attr("d", "M0,-5L10,0L0,5") 
     .attr("fill", "deepskyblue"); 

我希望能够淡出我的箭。对于箭杆,这个工程:

svg_.selectAll(".arrows") 
     .transition() 
     .duration(1000) 
     .style("stroke-opacity", 0.0) 
     .remove(); 

不过,虽然轴退色,箭头停留1000毫秒,然后突然消失。我试过fill-opacity就行了,试过selectAll.bluearrowhead但无济于事。有什么方法可以转换标记样式吗?

回答

5

与尝试:

svg_.selectAll(".arrows") 
    .transition() 
    .duration(1000) 
    .attr("opacity", 0.0) 
+0

完美,感谢 - 不知道了'opacity'属性为整个元素。 – pancake 2013-04-09 02:28:22