[英]Pie Chart using SVG
I want to create a pie chart that indicates progress 8/8 as whole and 4/8 as half. 我想创建一个饼状图,以指示进度整体为8/8,一半为4/8。 I already manage to create one but it seems that it started on the 90 degrees angle.
我已经设法创建一个,但它似乎是从90度角开始的。 i want it to start from 0 degrees.
我希望它从0度开始。 I dont want to use rotation because it has a Text inside
我不想使用旋转,因为它里面有一个文本
this is what i have so far 这就是我到目前为止
.pie-assign { border-radius: 50%; } .pie-assign circle { fill: yellow; stroke: red; stroke-width: 30; } .circle-0 { stroke-dasharray: 0 100; } .circle-1 { stroke-dasharray: 12.5 150; } .circle-2 { stroke-dasharray: 25 100; } .circle-3 { stroke-dasharray: 37.5 100; } .circle-4 { stroke-dasharray: 50 100; } .circle-5 { stroke-dasharray: 62.5 100; } .circle-6 { stroke-dasharray: 75 100; } .circle-7 { stroke-dasharray: 87.5 100; } .circle-8 { stroke-dasharray: 105 100; }
<div style="width:100px; height: 100px;"> <svg class="pie-assign" viewBox="0 0 30 30"> <circle class="circle-1" r="15" cx="15" cy="15" /> <text x="50%" y="50%" text-anchor="middle" fill="gray" dy=".3em">A</text> </svg> </div>
any help would be appreciated. 任何帮助,将不胜感激。
You can use rotation without rotating your text content. 您可以使用旋转而不旋转文本内容。
For example you can apply it to a <circle>
element: 例如,您可以将其应用于
<circle>
元素:
<circle r="15" cx="15" cy="15" transform="rotate(45,15,15)" />
The first value is the rotation in degrees. 第一个值是旋转度数。 Second and third value are the coordinates of the rotation center.
第二和第三个值是旋转中心的坐标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.