如何从海图的各个位置开始半圆甜甜圈图角度?

时间:2019-08-03 03:14:51

标签: javascript highcharts

如何将高图中的起始角度和终止角度设置为固定点。正如我尝试使用下面的代码。它的工作,但没有预期的。

plotOptions: { pie: { dataLabels: { enabled: true, distance: -50, style: { fontWeight: 'bold', color: 'white' } }, slicedOffset: 45, startAngle: -120, endAngle: 120, center: ['50%', '50%'], size: '110%' } },

输出应如下图所示。请检查fiddle

谢谢

1

1 个答案:

答案 0 :(得分:1)

尝试设置

plotOptions: {
    pie: {
       startAngle: -55,
       endAngle: 230,
       ...
    }
}

Highcharts.chart('container', {
  chart: {
    plotBackgroundColor: null,
    plotBorderWidth: 0,
    plotShadow: false
  },
  title: {
    text: 'Browser<br>shares<br>2017',
    align: 'center',
    verticalAlign: 'middle',
    y: -5,
    x: -110
  },
  tooltip: {
    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  },
  plotOptions: {
    pie: {
      dataLabels: {
        enabled: true,
        distance: -50,
        style: {
          fontWeight: 'bold',
          color: 'white'
        }
      },
      slicedOffset: 45,
      startAngle: -55,
      endAngle: 230,
      center: ['50%', '50%'],
      size: '110%'
    }
  },
  series: [{
    type: 'pie',
    name: 'Browser share',
    innerSize: '50%',
    data: [
      ['Chrome', 58.9],
      ['Firefox', 13.29],
      ['Internet Explorer', 13],
      ['Edge', 3.78],
      ['Safari', 3.42],
      {
        name: 'Other',
        dataLabels: {
          enabled: false
        }
      }
    ]
  }]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>

<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>