Вот как я это сделаю: я создаю путь id="segment"
, и я использую и поворачиваю его 6 раз:
let R = 45;// the outer radius
let r = 15;// the inner radius
//the radius for the text
let textR = r + (R - r)/2
// the angle for the slice
let A = Math.PI/3;
//points used to draw a slice
let p1 = {}
let p2 = {}
let p3 = {}
let p4 = {}
p1.x = r*Math.cos(-A/2);
p1.y = r*Math.sin(-A/2);
p2.x = R*Math.cos(-A/2);
p2.y = R*Math.sin(-A/2);
p3.x = R*Math.cos(A/2);
p3.y = R*Math.sin(A/2);
p4.x = r*Math.cos(A/2);
p4.y = r*Math.sin(A/2);
// the d attribute for the slice
let d =`M${p1.x},${p1.y} L${p2.x},${p2.y} A${R},${R} 0 0 1 ${p3.x},${p3.y} L${p4.x},${p4.y} A${r},${r} 0 0 0 ${p1.x},${p1.y}`;
// set the d attribute for the slice
sectorpath.setAttributeNS(null,"d", d);
// set the x and y attributes for the text
let text = document.querySelectorAll("#txt text")
text.forEach((t,i) =>{
let x = textR * Math.cos(A*i - Math.PI/2);
let y = textR * Math.sin(A*i - Math.PI/2);
t.setAttributeNS(null,"x",x);
t.setAttributeNS(null,"y",y);
})
svg{border:1px solid}
use{fill:blue; stroke:white; stroke-width:3}
<svg viewBox="-50 -50 100 100" width="300" >
<defs>
<path id="sectorpath" />
<mask id="themask">
<use xlink:href="#sectorpath" style="stroke:#000; stroke-width:3; fill: #ffffff"/>
</mask>
<use xlink:href="#sectorpath" id="sector" fill="blue" style="mask: url(#themask)" />
</defs>
<use xlink:href="#sector" transform="rotate(-90)" />
<use xlink:href="#sector" transform="rotate(-30)" />
<use xlink:href="#sector" transform="rotate(30)" />
<use xlink:href="#sector" transform="rotate(90)" />
<use xlink:href="#sector" transform="rotate(150)" />
<use xlink:href="#sector" transform="rotate(210)" />
</svg>