无法从数组中显示饼图

时间:2017-01-11 11:44:02

标签: javascript highcharts

我正在循环播放一个系列,但它不起作用,所以我正在寻找任何其他替代解决方案。

我的数组工作正常,但无法将该数组映射到Highcharts饼图。



var mssg = ["total more than 400","total less than 400 and greater than 300","total less than 300"];

arr4.length=8;

var percent=[22.33,44.33,33.33];

// code to push values into array series1 
for (var i = 0; i < arr4.length; i++) {
  series1.push({
    name: mssg[i],
    y: percent[i]
  });

}

// highchartcode
Highcharts.chart('container2', {
  chart: {
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false,
    type: 'pie'
  },
  title: {
    text: 'Pie chart according to total'
  },
  tooltip: {
    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      cursor: 'pointer',
      dataLabels: {
        enabled: true,
        format: '<b>{point.name}</b>: {point.percentage:.1f} %',
        style: {
          color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
        }
      }
    }
  },
  series: [{
    name: 'Total',
    colorByPoint: true,

    data: series1
   

  }]
});
&#13;
&#13;
&#13;

0 个答案:

没有答案