複数のチャートがあり、1つの更新機能でこれらを更新する方法を理解できないようです。
私はHTMLファイルを持っています、そのファイルに私はこれを持っています:
<script type="text/javascript" src="highchart/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="highchart/highcharts.js"></script>
<script type="text/javascript" src="highchart/highcharts-more.js"></script>
<script type="text/javascript" src="windspeed.js"></script>
<script type="text/javascript" src="livedata.js"></script>
windspeed.js:
$(function () {
var windspeed = new Highcharts.Chart({
chart: {
renderTo: 'windspeed',
type: 'gauge',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false
},
etc.
}
livedata.js:
$(function (livedata) {
setInterval(function() {
$(function() {
$.getJSON('livedata.php', function(data) {
$.each(data, function(key,val) {
if (key == 'WindSpeed')
{
var point = windspeed.series[0].points[0];
point.update(val);
}
});
});
})
},2000)
}
);
チャートはポップアップしますが、データは更新されません。次のエラーが発生します:プロパティ「0」の値を取得できません:オブジェクトがnullまたは未定義
ですこれは、livedata.jsが風速変数を認識できないために何か関係があると思います別のスコープで。
誰かがこれを機能させる方法を教えてもらえますか?