Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Highcharts未加载带有json数据的图表_Javascript_Json_Highcharts - Fatal编程技术网

Javascript Highcharts未加载带有json数据的图表

Javascript Highcharts未加载带有json数据的图表,javascript,json,highcharts,Javascript,Json,Highcharts,我正在为我的应用程序使用highcharts。当我使用下面的代码时,图表被渲染 obj.series=[{ type: 'pie', name: 'Fruits', data: [ ['Apple', 80.0], ['Mango', 20.0] ] }] obj.series.data=[['Apple', 43],['Pear',57.0]]; //this data I get from the server. 但是我需要通过对服务器进行a

我正在为我的应用程序使用highcharts。当我使用下面的代码时,图表被渲染

 obj.series=[{
  type: 'pie',
  name: 'Fruits',
  data: [
    ['Apple',   80.0],
    ['Mango', 20.0]
    ]
  }]
obj.series.data=[['Apple', 43],['Pear',57.0]]; //this data I get from the server.
但是我需要通过对服务器进行ajax调用来获取数据。因此,当我从服务器获取json响应并使用下面的代码设置数据时,图表不会呈现

 obj.series=[{
  type: 'pie',
  name: 'Fruits',
  data: [
    ['Apple',   80.0],
    ['Mango', 20.0]
    ]
  }]
obj.series.data=[['Apple', 43],['Pear',57.0]]; //this data I get from the server.
你能告诉我哪里出了问题吗

我正在更新下面的完整代码:

var chartObj = {
        chart: {
          plotBackgroundColor: null,
          plotBorderWidth: null,
          plotShadow: false,
          backgroundColor:null
        },
        tooltip: {
          pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
          pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
              enabled: true,
              color: '#000000',
              connectorColor: '#000000',
              format: '<b>{point.name}</b>: {point.percentage:.1f} %'
            }
          }
        },
        navigation: {
          buttonOptions: {
            enabled: false
          }
        },
        title:{
          text: 'Storage Data'
            },
        series:[{
          type: 'pie',
          name: 'Storage Data',
          /*data: [
            ['HP',   80.0],
            ['DELL', 20.0]
            ]*/
            }]
        }

         var storageData = $.getJSON('http://hostname/resturl/data', 
           function(data) { 
          var result = new Array();
          for (i=0;i<data.content.length;i++) {
              var alpha = new Array();
                      alpha.push(data.content[i].x);
              alpha.push(data.content[i].y);
                  result.push(alpha);
          }
            storageobj.series.data=result;       
          });
      $('#pie-chart2').highcharts(storageobj);

请显示完整代码。请确保json中有数字值。您在控制台中收到任何错误吗?我已经用当前代码更新了问题。请告诉我哪里出错了。控制台上没有错误。当我删除
data
部分中的注释时,它可以正常加载,但是当我尝试使用ajax获取数据时,它不会呈现图表。控制台上也没有错误。请以实时方式回复您的演示