2015-11-18 64 views
0

您好我正在使用json值繪製餅圖highchart我有以下格式的json值。從json值繪製餅圖HighCharts,

Data= {"count":[62,58,10,6],"categoires":["a1","a2","a3","a4"]} 

喜有Highchart的像這樣的代碼

  $('#2Chieldrightdiv').highcharts({ 
       chart: { 
        plotBackgroundColor: null, 
        plotBorderWidth: null, 
        plotShadow: false, 
        type: 'pie' 
       }, 
       title: { 
        text: 'Browser market shares January, 2015 to May, 2015' 
       }, 
       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} %', 
         }, 
         showInLegend: true 
        } 
       }, 
       series: [{ 
        name: 'Brands', 
        colorByPoint: true, 
        data: [{ 
         name: cat, 
         y: Count 
        }] 
       }] 
      }); 

     } 

但圖表不拉絲我在Highchart新,所以請大家幫我理清這個問題。

謝謝

+0

嘗試刪除任何及所有,但最需要的選項,使圖表後添加您需要的各種選項,看看當它停止繪製自己。 – ObedMarsh

回答

0

原因是你指單點的點陣列。因此,您有類似:

series: [{ 
       name: 'Brands', 
       colorByPoint: true, 
       data: [{ 
        name: ["a1","a2","a3","a4"], 
        y: [62,58,10,6] 
       }] 
      }] 

但你應該有:

data: [{ 
         name: "a1", 
         y: 62 
     },{ 
         name: "a2", 
         y: 58 
     },{ 
         name: "a3", 
         y: 10 
     },{ 
         name: "a4", 
         y: 6 
     }]