我整天都在研究这个 HighCharts 示例,但无法让它全部工作。我正在显示在 getJSON 调用中检索到的几个数据系列。该图表被放入其容器 DIV 中,但没有绘制数据,javascript 控制台上也没有错误。
我认为问题一定出在 JSONP 调用格式中,但我看不出它有任何问题。JSONP 服务在这里:http://199.38.183.107/ow/fludata.php?callback=?
<html>
<head>
<title>Demonstration of web service</title>
<style type="text/css">
.chart-container {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="container" style="width: 100%; height: 400px;"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"> </script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script>
$(function () {
$.getJSON('http://199.38.183.107/ow/fludata.php?callback=?', function(data){
$('#container').highcharts({
chart: {
type: 'spline'
},
title: {
text: 'Weekly influenza infection counts'
},
subtitle: {
text: 'Data series show the CDC Regions'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
}
},
yAxis: {
title: {
text: 'Number of infections reported'
},
min: 0
},
plotOptions: {
series: {
marker: {enabled: false},
turboThreshold: 1000000,
states: {hover: {enabled: false}}
}
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+ Highcharts.dateFormat('%e. %b', this.x) +': '+ this.y +' m';
}
},
series: data,
credits: { enabled: false }
}); //container
}); //getJSON
}); //function