Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度,svg-在svg中动态创建圆_Angular_Svg - Fatal编程技术网

Angular 角度,svg-在svg中动态创建圆

Angular 角度,svg-在svg中动态创建圆,angular,svg,Angular,Svg,我一直在使用这篇文章创建svg饼图 我这里有一个exmapke,它使用angular从一个数据数组中创建3个独立的饼图 我现在需要创建一个饼图,将所有部分都放在一个图表上 是否可以使用Angular之类的工具在svg中创建圆 <circle *ngFor="let dount of dountData; let i = index;" class="donut-segment" cx="21" cy="21" r="15.91549430918954"

我一直在使用这篇文章创建svg饼图

我这里有一个exmapke,它使用angular从一个数据数组中创建3个独立的饼图

我现在需要创建一个饼图,将所有部分都放在一个图表上

是否可以使用Angular之类的工具在svg中创建圆

<circle 
  *ngFor="let dount of dountData; let i = index;"
  class="donut-segment" 
  cx="21" 
  cy="21" 
  r="15.91549430918954" 
  fill="transparent" 
  [attr.stroke]="donut.color" 
  stroke-width="3" 
  [attr.stroke-dasharray]="donut.percent + ' ' + (100 - donut.percent)"
  [attr.stroke-dashoffset]=strokeDashOffset>
</circle>

当然,在同一个svg中绘制所有的圆,而不是三个单独的svg。下面是修改后的
donuts.template.html
代码,用于在同一个svg中绘制它们:

<div>
  <svg width="100%" height="100%" viewBox="0 0 42 42" class="donut">
    <circle class="donut-hole" 
        cx="21" 
        cy="21" 
        r="15.91549430918954"
        fill="#fff"></circle>
    <circle class="donut-ring" 
        cx="21" 
        cy="21" 
        r="15.91549430918954" 
        fill="transparent" 
        stroke="#d2d3d4" 
        stroke-width="3"></circle>

    <g *ngFor="let donut of donutData; let i = index;">
    {{updatePercent(i, donut)}} 

      <circle class="donut-segment" 
          cx="21" 
          cy="21" 
          r="15.91549430918954" 
          fill="transparent" 
          [attr.stroke]="donut.color" 
          stroke-width="3" 
          [attr.stroke-dasharray]="donut.percent + ' ' + (100 - donut.percent)"
          [attr.stroke-dashoffset]=strokeDashOffset></circle>
    </g>
  </svg>
</div>

{{updatePercent(i,甜甜圈)}