我在試圖刪除動畫餅圖上相當醜陋的工件時遇到了問題。它在Chrome上運行得非常好,只有(11或邊緣)和Firefox似乎有問題。SVG圓形筆畫,僅限IE和Firefox的圖形工件(Windows)
讓我們先從一個截圖中,你會立即看到什麼問題:
醜陋的Firefox版本:
完美的Chrome版本:
正如你所看到的,Firefox上有一個非常奇怪的圖形化錯誤。我無法理解渲染引擎爲什麼這樣做。
編輯:請注意它的主題相關的筆畫寬度/ SVG元件的尺寸
讓我解釋一下什麼是真正發生在這裏:
<figure id="pie" data-percentage="20" data-behavior="pie-chart">
<svg>
<!-- Radius has to be svg diameter divided by 4 -->
<!-- Cx and cy have to be svg diameter divided by 2 -->
<circle r="100" cx="100" cy="100"/>
<circle r="50" cx="100" cy="100"/>
</svg>
<div class="receiver"></div>
</figure>
基本上我有一個藍色的圓圈,沒有中風。最重要的是,我有另一個藍色的圓圈,但有一個綠色的中風。爲了將餅圖「填充」到一個給定的值,我使用了js的動畫dasharray,因此是動畫餅圖。
但是正如您所看到的,非webkit瀏覽器存在一個大問題。 我在css中使用當然的幾何精度。
You can see all my code on the codepen
而這裏僅僅是一個最小的SVG版本。
svg {
height: 200px;
width: 200px;
transform: rotate(-90deg);
}
circle:nth-child(1) {
fill: #4d80b3;
stroke-width: 0;
}
circle:nth-child(2) {
fill: #4d80b3;
stroke: #9cc374;
stroke-dasharray: 0, 314.159;
stroke-width: 100px;
transition: stroke-dasharray 2000ms cubic-bezier(0.215, 0.61, 0.355, 1) 0s;
}
<svg>
<circle cy="100" cx="100" r="100"/>
<circle cy="100" cx="100" r="50" style="stroke-dasharray: 62.8319, 314.159;"/>
</svg>
爲什麼在Firefox 41中值得我看不到這個問題。 (或Firefox 43)。也許你使用的是舊版本的Firefox,它有一個現在已修復的錯誤? –
嗨,你確定嗎?也許這個百分比隱藏了問題。我刪除了codepen上的百分比,以避免這個 –
我也刪除了%。 –