我需要一些帮助来转换下面的代码,以便从数据库返回的值中构建系列数据。
var options = {
"chart": {
"type": "column",
"zoomType": "xy",
"inverted": true
},
"plotOptions": {
"series": {
"stacking": "percent"
},
"column": {
"allowPointSelect": true
},
"bar": {
"selected": true
}
},
"title": {
"text": "MT Messages"
},
"xAxis": {
"title": {
"text": null
},
"type": "category"
},
"series": [
{
"index": 0,
"dataLabels": {
"enabled": true
},
"name": 101,
"data": [
[
"Today",
5
],
[
"This Week",
3
],
[
"Last Week",
4
],
[
"Last Month",
127
]
]
},
{
"index": 1,
"dataLabels": {
"enabled": true
},
"name": 103,
"data": [
[
"Today",
2
],
[
"This Week",
2
],
[
"Last Week",
3
],
[
"Last Month",
20000
]
]
},
{
"index": 2,
"dataLabels": {
"enabled": true
},
"name": 202,
"data": [
[
"Today",
3
],
[
"This Week",
4
],
[
"Last Week",
4
],
[
"Last Month",
2
]
]
}
]
};
我已将其替换为:
var data = [['Today', 12], ["This Week", 13], ["Last Week", 23], ["Last Month", 100]];
var barChart = $(function() {
$('#barChart').highcharts({
"chart": {
"type": "column",
"zoomType": "y",
"inverted": false
},
"plotOptions": {
"series": {
"stacking": "percent"
},
"column": {
"allowPointSelect": true
},
"bar": {
"selected": true
}
},
"title": {
"text": "MT Messages"
},
"xAxis": {
"title": {
"text": null
},
"type": "category"
},
"series": [
{
"index": 0,
"dataLabels": {
"enabled": true
},
"name": 101,
"data":data
},
{
"index": 1,
"dataLabels": {
"enabled": true
},
"name": 103,
"data": data
},
{
"index": 2,
"dataLabels": {
"enabled": true
},
"name": 202,
"data":data
}
]
});
});
但是,我的所有列都包含每个索引的相同值
我可能看错了,也许我的数组需要是这样的:
data = ['今天',12,13,52],['本周', 123,3466,56]...等
但这根本无法呈现图表。