我有这个 JSON 数组:
[{"name":"test1","data":[[1361574000000,0],[1362006000000,40.6],[1363388400000,35.7], [1363820400000,41.24],[1364511600000,40.56],[1365112800000,38.96],[13655544800000,39.8] [1368655200000,41.31],[1369346400000,40.16]]},{"name":"test2","data":[[1361574000000,0], [1362006000000,1.46],[1363388400000,1.42],[1363820400000,1.42],[1364511600000,1.37], [1365112800000,1.41],[1365544800000,1.41],[1366063200000,1.35],[1366668000000,1.45], [1367272800000,1.36],[1368309600000,1.36],[1368655200000,1.36],[1369346400000,1.37]]}]
我相信这是一种有效的 JSON 格式,对吗?
不幸的是,使用此代码仅绘制了一个空图:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script type="text/javascript">
$(function() {
$.getJSON('testdata.php', function(data) {
// Create the chart
$('#container').highcharts('StockChart', {
title : {
text : 'Test'
},
series : [{
name : 'Test',
data : data,
tooltip: {
valueDecimals: 2
}
}]
});
});
});
</script>
</head>
<body>
<div id="container" style="height: 500px; min-width: 500px"></div>
</body>
</html>
我怎样才能让它正常工作?我已经阅读了一些 Highcharts 文档,但是我没有足够的编程经验来让它工作。
谢谢!