Highcharts学习笔记-饼状图(内存使用监视)

function show(arr) {
      //alert(arr);
      var chart = new Highcharts.Chart({
        chart: {
          renderTo: 'container',
          plotBackgroundColor: null,
          plotBorderWidth: null,
          plotShadow: false
        },
        title: {
          text: 'Browser market shares at a specific website, 2010'
        },
        tooltip: {
          formatter: function() {
            return '<b>' + this.point.name + '</b>: ' + this.y + ' MB';
          }
        },
        plotOptions: {
          pie: {
            allowPointSelect: false,
            cursor: 'pointer',
            dataLabels: {
              enabled: true,
              color: '#000000',
              connectorColor: '#000000',
              formatter: function() {
                return '<b>' + this.point.name + '</b>: ' + this.y + ' %';
              }
            }
          }
        },
        series: [
          {
            type: 'pie',
            name: 'Browser share',
            data: arr
          }
        ]
      });
    }

 2、post请求数据

$.post("${createLink(controller:'main',action:'pie')}", {type:'json'}, function(data) {
        var arr = new Array();
        for (var i = 0; i < data.length; i++) {
          var tmp = new Array();
          tmp[0] = data[i].name;
          tmp[1] = data[i].memSize/1024;
          arr[i] = tmp;
        }
        show(arr);
      });

3、显示结果:


Highcharts学习笔记-饼状图(内存使用监视)_第1张图片

 

你可能感兴趣的:(js,Highcharts,饼状图)