在highcharts组合图中传递Ajax数据
Pass Ajax data in highcharts Combination chart
我试图在组合图中传递数据(行数据和pie_data)。我可以传递pie_data,但无法传递行数据。这是我的jsFiddle链接
请告诉我哪里出了问题?
这是我的密码。
$(function () {
var line_data = [{ // this is AJAX returned line_data.
'data': [
[1383741000000, 1608.3000000000002],
[1383741900000, 1611.9999999999973],
[1383742800000, 1612.299999999997]
],
'name': 'Bangalore'
}, {
'data': [
[1383741000000, 54.2],
[1383741900000, 54.300000000000004],
[1383742800000, 54.300000000000004]
],
'name': 'New Delhi'
}];
// this is AJAX returned pie_data.
// I'm able to get the pie chart, but not the line chart.
var pie_data = [['Jane',13], ['Jnanae',33] , ['Jasvdwdne',113]];
$('#container').highcharts({
chart: {
},
title: {
text: 'Combination chart'
},
xAxis: {
type: 'datetime'
},
series: [{
type: 'spline',
name: 'Average',
data: line_data,
marker: {
lineWidth: 2,
lineColor: Highcharts.getOptions().colors[3],
fillColor: 'white'
}
}, {
type: 'pie',
name: 'Total consumption',
data: pie_data,
center: [100, 80],
size: 100,
showInLegend: false,
dataLabels: {
enabled: false
}
}]
});
});
试试这个:-http://jsfiddle.net/5yzb2/6/
JS:-
$(function () {
var seriesOptions = [];
var line_data = [{ // this is AJAX returned line_data.
data: [
[1383741000000, 1608.3000000000002],
[1383741900000, 1611.9999999999973],
[1383742800000, 1612.299999999997]
],
name: 'Bangalore'
}, {
data: [
[1383741000000, 54.2],
[1383741900000, 54.300000000000004],
[1383742800000, 54.300000000000004]
],
name: 'New Delhi'
}];
// this is AJAX returned pie_data.
// I'm able to get the pie chart, but not the line chart.
var pie_data = [
['Jane', 13],
['Jnanae', 33],
['Jasvdwdne', 113]
];
//Adding all data seriesOptions
$.each(line_data, function (i, name) {
seriesOptions[i] = {
type: 'spline',
name: this.name,
data: this.data
};
});
seriesOptions[seriesOptions.length] = {
type: 'pie',
name: 'Total consumption',
data: pie_data,
center: [100, 80],
size: 100,
showInLegend: false,
dataLabels: {
enabled: false
}
};
$('#container').highcharts({
chart: {},
title: {
text: 'Combination chart'
},
xAxis: {
type: 'datetime'
},
tooltip: {
formatter: function () {
var s;
if (this.point.name) { // the pie chart
s = '' + this.point.name + ': ' + this.y + ' fruits';
} else {
s = '' + this.x + ': ' + this.y;
}
return s;
}
},
labels: {
items: [{
html: 'Total fruit consumption',
style: {
left: '40px',
top: '8px',
color: 'black'
}
}]
},
series: seriesOptions
});
});
相关文章:
- React ajax数据集成
- 使用jQuery发布的AJAX数据包含引号
- 如何将Ajax数据值分配给PHP变量
- 使用外部ajax数据PHP绘制图表
- 如何打印AJAX数据
- AJAX数据包含一个或多个单词.
- 将Ajax数据发布到PHP REST服务
- AJAX 数据响应 - 如何解析 html
- 将 Ajax 数据分配给全局变量时出现问题
- 按钮在第一次成功的 ajax 数据加载后不起作用
- Javascript / JQuery循环访问已发布的ajax数据字符串以为其分配新值
- 发送的 Ajax 数据不起作用
- Jquery 工具提示未随 AJAX 数据加载一起显示
- Ajax获取数据以获取另一个Ajax数据
- 如何安全地依赖现有的Ajax数据
- 如何将jquery ajax数据提取为html
- 自定义AJAX数据类型
- 如何将ajax数据发送到rails 3.jQuery正在转义字符串
- jQuery AJAX数据参数
- Laravel 4:通过控制器操作ajax数据