我正在尝试使用带有symfony2的ObHighcharts包。
基本上,它会生成以下代码:
$(function () {
var chart = new Highcharts.Chart({
chart: {"renderTo":"dailyChart","type":"spline"},
series: {"name":"My spline","data":
[
[1369519200,"2055.5"],
[1370469600,"1986.3"],
[1369087200,"1804.0"],
[1368655200,"1783.3"],
[1366840800,"1734.3"],
[1369000800,"1693.2"],
[1368309600,"1515.4"],
*lots of other similar data*
]
},
title: {"text":"My Chart"},
xAxis: {"title":{"type":"datetime","title":"Date"}},
yAxis: {"title":{"title":"Sugar, mg","min":0}}
});
});
但是当我尝试渲染它时,只有一个标题,一个导出按钮和一个空白屏幕。控制台没有显示错误的迹象。这可能有什么不对?感谢任何意见。
答案 0 :(得分:1)
因为您的数据元素是一个字符串:
[
[1369519200,"2055.5"],
[1370469600,"1986.3"],
[1369087200,"1804.0"],
[1368655200,"1783.3"],
[1366840800,"1734.3"],
[1369000800,"1693.2"],
[1368309600,"1515.4"],
*lots of other similar data*
]
应该是[1369519200,2055.5]
之类的东西。
您还需要将系列元素括在括号中:
series: [{"name":"My spline","data":
[
[1369519200,"2055.5"],
[1370469600,"1986.3"],
[1369087200,"1804.0"],
[1368655200,"1783.3"],
[1366840800,"1734.3"],
[1369000800,"1693.2"],
[1368309600,"1515.4"],
]}
]
另请注意,您的时间元素不是按升序排列的。对于正确的日期时间轴,您需要进入升序时间。