【发布时间】:2014-12-19 09:09:03
【问题描述】:
我想通过 JSON 数组将一些图形参数传递给图形。其中,它应该是图表的标题、单位、……以及数据。
一旦我开始尝试将 JSON 数组从一个简单的“数据”数组转换为可以容纳更多信息的数组,它就不再起作用了。我想这与我使用的那种括号有关。对哪些是正确的感到困惑。
我把它放在into a fiddle。
$(function () {
var options = {
chart: {
renderTo: 'container',
type: 'spline',
marginBottom: 50
},
xAxis: {
},
title:
{
text: "Title",
align: "center",
},
plotOptions:
{
series:
{
marker:
{
enabled: false
}
}
},
series: [{}]
};
/* This works
data = [
{
"name": "France",
"data": [[2006,2189260],[2007,2239300],[2008,2237490],[2009,2167070],[2010,2204450]]
}
];
*/
/* This doesn't */
data = [
{
"series":
[{
"name": "France",
"data": [[2006,2189260],[2007,2239300],[2008,2237490],[2009,2167070],[2010,2204450]]
}]
}
];
/* load the stuff in the JSON like this= */
options.series = data["series"];
var chart = new Highcharts.Chart(options);
});
非常感谢任何提示我做错了什么。
【问题讨论】:
标签: arrays json highcharts