javascript Highcharts甜甜圈图代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Highcharts甜甜圈图代码相关的知识,希望对你有一定的参考价值。

/**
 * Creates a donut graph using Highcharts and places in page
 * @param {array} dataToUse - takes an array of objects
 * @param {element} container - element to place chart into
 */
function createDonutGraph(dataToUse, container) {
  const graphData = [];

  for (let dataToUseCount = 0; dataToUseCount < dataToUse.length; dataToUseCount++) {
    graphData.push({
      y: dataToUse[dataToUseCount].drilldown.data[0],
      color: dataToUse[dataToUseCount].color
    });
  }

  Highcharts.chart(container, {
    chart: {
      type: 'pie',
      height: 135,
      width: 135,
      margin: 0,
      renderTo: 'chart',
      spacingTop: 0,
      spacingBottom: 0,
      spacingLeft: 0,
      spacingRight: 0
    },
    title: {text: undefined},
    tooltip: {enabled: false},
    legend: {enabled: false},
    subtitle: {enabled: false},
    credits: {enabled: false},
    plotOptions: {
      pie: {
        allowPointSelect: true,
        cursor: 'pointer',
        dataLabels: {enabled: false},
        borderWidth: 0,
        slicedOffset: 0
      }
    },
    series: [{
      name: 'Seats',
      data: graphData,
      size: '100%',
      innerSize: '85%',
      enableMouseTracking: false
    }]
  });
}

以上是关于javascript Highcharts甜甜圈图代码的主要内容,如果未能解决你的问题,请参考以下文章

R语言使用ggplot2可视化甜甜圈图(Donut chart)

Chartjs 带有渐变颜色的甜甜圈图

使用nvd3.js自定义甜甜圈图

渐进式<;svg>;饼图、甜甜圈图、条形图和折线图

当数据值为 0 时,Django Chartjs 输出“无数据”

熊猫系列的彩色饼图