gpt4 book ai didi

html - 使用 SVG 的饼图

转载 作者:太空宇宙 更新时间:2023-11-04 02:14:13 31 4
gpt4 key购买 nike

我想创建一个饼图来指示进度 8/8 作为整体,4/8 作为一半。我已经设法创建了一个,但它似乎是从 90 度 Angular 开始的。我希望它从 0 度开始。我不想使用旋转,因为它里面有一个文本

这就是我目前所拥有的

.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>

如有任何帮助,我们将不胜感激。

最佳答案

您可以在不旋转文本内容的情况下使用旋转。

例如,您可以将其应用于 <circle>元素:

<circle r="15" cx="15" cy="15" transform="rotate(45,15,15)" />

第一个值是以度为单位的旋转。第二个和第三个值是旋转中心的坐标。

关于html - 使用 SVG 的饼图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39168373/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com