javascript - HighChart isn't plotting data correctly -
hi i'm using high chart , data coming through okay date not coming through on x axis, have parameter in data correctly formatted date , i'd use on x axis , popup, understand need use utc datetime order properly
function buildandupdatetempchart() { $.getjson('server/getreadings.php', function (data) { $('#chartcontainer').highcharts('stockchart', { chart:{ events: { load: function(){ // set updating of chart each second //debugger; // var series = this.series[0]; // //console.log('data is: ' + data); // for(var = 0; < data.length - 1; i++){ // this.series[0].addpoint(data[i].temp, data[i].timestamp, true, true); // this.series[1].addpoint(data[i].atemp, data[i].timestamp, true, true); // } // setinterval(function () { // //get tick // var x = (new date()).gettime(), // current time // y = math.round(math.random() * 100); // series.addpoint([x, y], true, true); // }, 1000); } } }, title: { text: 'temperature sensor readings' }, yaxis: { title: { text: 'degrees celcius' }, plotlines: [{ value: -10, color: 'green', dashstyle: 'shortdash', width: 2, label: { text: 'minimum tolerated.' } }, { value: 20, color: 'red', dashstyle: 'shortdash', width: 2, label: { text: 'maximum tolerated.' } }]}, plotoptions: { series: { compare: 'percent' } }, series: [{ name: 'temp', data: (function () { var temp = []; (var = 0; < data.length; i++) { temp.push([ data[i].timestamp, parsefloat(data[i].temp) ]); } return temp; }()), tooltip: { valuedecimals: 2 }}, { name: 'ambient temp', data: (function () { var atemp = []; (var = 0; < data.length; i++) { atemp.push([ data[i].timestamp, parsefloat(data[i].atemp) ]); } return atemp; }()), tooltip: { valuedecimals: 2 }, }] }); }) } $(document).ready(function(){ buildandupdatetempchart(); //this async there rest of app can continue work });
my guess need
xaxis: { type: 'datetime' },
in code. hope helps.
Comments
Post a Comment