highcharts getjson php文件,PHP JSON Highcharts load database result

In your ajax call -

$.getJSON('ajax/calc.ajax.php', function(data) {

var series = []; //

So, it would be as follows -

$.getJSON('ajax/calc.ajax.php', function(data) {

$.each(data, function(key, value) {

var series = {}; //

Also, considering the JSON you are receiving -

{"nome":"TRANSFORMADOR 250VA 0-230-380V / 0,24V-0-48V","modelo":"TRANSFORMADOR","marca":"SEIT","valor":"318.87|542.08","qtdade":"0"??}

what you are doing in the $.each -

series.data = value;

does not make sense.

series.data is an array. So, it could look like either as follows -

[y1, y2, y3, ....] // array of numbers (which are y values)

or as follows -

[[x1, y1], [x2, y2], [x3, y3], ....] // array of arrays of pair of numbers (x and y values)

or as follows -

// array of objects which can have x and y values as properties

[{

name: 'Point 1',

color: '#00FF00',

y: 0

}, {

name: 'Point 2',

color: '#FF00FF',

y: 5

}]

So, make sure that your PHP code produces a JSON that matches an array of one of the above, then series.data = value inside your $.each will work.

Update:

Sorry, I do Java and have never done PHP so can't help you much with PHP. But, can you try with the following as your PHP, just to see if the chart shows up?

header('Content-Type: application/json');

$return_data = array(

array(array(10, 20), array(20, 30), array(56, 30), array(50, 20)),

array(array(10, 0), array(20, 10), array(56, 100), array(50, 40))

);

echo json_encode($return_data);

Update: To render pie while keeping the same PHP.

$.getJSON('ajax/calc.ajax.php', function(data) {

var series = { //

This should draw pie chart.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值