我希望我使用的是正確的術語,但基本上我試圖在D3中的餅圖頂部創建高亮。我已經看到了很多關於添加陰影的東西,但一直無法使其突出顯示。所以,我嘗試在圖表頂部添加一個弧線並添加一個高斯模糊,但有兩個問題:它不會與圖表的其餘部分進行轉換,並且突出顯示會延伸到圖表上方,我可以' t似乎讓它保持在圖表的邊緣。有沒有辦法在d3中添加一個高亮顯示到餅圖?
下面是一個例子:http://jsfiddle.net/hf3adsj5/
我使用嘗試添加高亮的代碼如下:
var arc2 = d3.svg.arc()
.innerRadius(innerRadius)
.outerRadius(outerRadius)
.startAngle(Math.PI/4)
.endAngle(-7/12*Math.PI);
var filter2 = defs.append("filter")
.attr("id","highlight");
filter2.append("feGaussianBlur")
.attr("in","SourceAlpha")
.attr("stdDeviation",2)
.attr("result","blur");
filter2.append("feColorMatrix")
.attr("in", "blur")
.attr("type", "matrix")
.attr("values", "0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0")
.attr("result", "whiteblur");
filter2.append("feOffset")
.attr("in","whiteblur")
.attr("dx",3)
.attr("dy",3)
.attr("result","offsetBlur");
var feMerge2 = filter2.append("feMerge");
feMerge2.append("feMergeNode")
.attr("in","offsetBlur");
feMerge2.append("feMergeNode")
.attr("in","SourceGraphic");
svg.append("path")
.attr("d",arc2)
.style("filter","url(#highlight)");
有沒有辦法做到這一點無需增加額外的弧線?或者至少讓它像投影一樣轉變?
你是如何做餅圖轉換?你可以創建一個jsFiddle或Plunker來重現這個問題嗎? – Mark 2015-04-01 18:37:55
@Mark請參閱編輯。 – josh 2015-04-01 20:14:05