SVG圈上的文字

时间:2019-04-16 05:49:54

标签: html html5 svg highcharts

我正尝试显示SVG颜色,如上图所示

chart

这是JSfiddle https://jsfiddle.net/3cx6mLy0/

我可以创建颜色,但文本不显示

series: [{
        name: 'Move',
        data: [{
            color:  '#FF0000',
            radius: '112%',
            innerRadius: '65%',
            y: 60
        }]
    }, {
        name: 'Exercise',
        data: [{
            color: 'green',
            radius: '112%',
            innerRadius: '65%',
            y: 20
        }]
    }]
});

能否请您告诉我解决此问题的确切方式

1 个答案:

答案 0 :(得分:2)

您可以使用dataLabelslegend属性来获得所需的结果:

  plotOptions: {
      solidgauge: {
          ...,
          dataLabels: {
              formatter: function() {
                  var series = this.series.chart.series,
                      index = this.series.index;

                  if (index !== series.length - 1) {
                      return (this.y - series[index + 1].points[0].y) + '%'
                  }
                  return this.y + '%'
              }
          }
      }
  }

实时演示: https://jsfiddle.net/BlackLabel/ay5mbfew/

API参考:

https://api.highcharts.com/highcharts/plotOptions.series.dataLabels.enabled

https://api.highcharts.com/highcharts/plotOptions.series.showInLegend