2013-04-08 92 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