svg绘制pie饼图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/59095c70b1e93e0237befff31d7b4b63.png)
let arr=[300,200,100,240];
let color=["red","#41e","blue"];
let labels=["1","2","3","4"];
let pieData = pieChart(arr,300,300,120,120,80,color,labels,200,100);
console.log(pieData);
document.getElementById("svg").appendChild(pieData);
function pieChart(data,width,height,cx,cy,r,colors,labels,lx,ly){
let svgns = "http://www.w3.org/2000/svg";
let chart=document.createElementNS(svgns,"svg:svg");
chart.setAttribute("width",width);
chart.setAttribute("height",height);
chart.setAttribute("viewBox","0 0 " + width + " " + height);
let total = 0;
for(let i=0;i<data.length;i++){
total += data[i];
}
let angles = [];
for(let i=0;i<data.length;i++){
angles[i] = data[i]/total * Math.PI*2;
}
let anglesExp=null
for(let i=0;i<angles.length;i++