1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
function requestData() {
$.ajax ({
type:"get" ,
url: "<?php echo CController::createUrl('beam/GetSensorsDataLive') ?>",
data: {"beamId" : "<?php echo $modelBeam['poutre_id'] ?>" },
dataType: "json",
success: function(response,point) {
var series = chart.series[0], //// error here
shift = series.data.length > 20;// shift if the series is longer than 20
chart.series[0].addPoint( point,true, false); // add the point
setTimeout(requestData, 1000); // call it again after one second
},
cache: false
});
}
$(document).ready(function() {
var chart;
chart = new Highcharts.Chart({
chart: {
renderTo: 'graph',
type: 'spline',
events: {
load: requestData
}
},
xAxis: {
type: 'datetime',
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%H:%M:%S:%m', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
series: [{
name: 'Live Data From sensor <?php echo $modelBeam['poutre_id'] ;?> ',
data:[]
}]
});
}); |
Partager