highcharts pie ajax,Ajax JSON in to Highcharts Pie Chart

I have been encountering issues for the past few days with ajaxing in some sample json data from an external file to populate a pie chart using the Highcharts library.

Here is my sample JSON data in file: data.json

[

["Apples", 43.0],

["Pears", 57.0]

]

Here is my implementation of highcharts and my AJAX call:

(I have omitted unrelated code)

$(function() {

var options = {

chart: {

renderTo: 'Chart',

defaultSeriesType: 'pie'

},

title: {

text:'Fruits'

},

plotOptions: {

pie: {

allowPointSelect: true,

cursor: 'pointer',

dataLabels: {

enabled: true,

color: '#000000',

connectorColor: '#000000',

}

}

},

series: [{

type: 'pie',

name: 'Fruits',

data: []

}]

};

$.getJSON('data.json', function(json) {

options.series.push(json);

var chart = new Highcharts.Chart(options);

}).error(function() {console.log('error');});

});

Basically, I want to pass in the JSON, into options.series[].data[]. When proceed with

options.series.push(json);

I get:

[Object, Array[2]] // where the Object contains .name and .type and the Array[2] is my data

I'm pretty sure I need this:

[Object] // which contains .data , .name, .type

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值