Javascript 海图是';t正确绘制数据
您好,我使用的是high chart,数据通过了OK,但是日期在x轴上没有通过,我在数据中有一个参数,具有正确格式的日期,我想在x轴和弹出窗口上使用该参数,但是我知道我需要使用UTC datetime来正确排序Javascript 海图是';t正确绘制数据,javascript,highcharts,Javascript,Highcharts,您好,我使用的是high chart,数据通过了OK,但是日期在x轴上没有通过,我在数据中有一个参数,具有正确格式的日期,我想在x轴和弹出窗口上使用该参数,但是我知道我需要使用UTC datetime来正确排序 函数buildAndUpdateTempChart(){ $.getJSON('server/getReaders.php',函数(数据){ $(“#chartContainer”)。highcharts('StockChart'{ 图表:{ 活动:{ 加载:函数(){ //设置图表的
函数buildAndUpdateTempChart(){
$.getJSON('server/getReaders.php',函数(数据){
$(“#chartContainer”)。highcharts('StockChart'{
图表:{
活动:{
加载:函数(){
//设置图表的每秒更新
//调试器;
//var系列=本系列[0];
////console.log('数据为:'+数据);
//对于(var i=0;i
我猜你需要
xAxis: {
type: 'datetime'
},
在你的代码中。希望这有帮助。我想你需要
xAxis: {
type: 'datetime'
},
在你的代码中。希望这有帮助。这可以帮助您,您必须指定xAxis a
datetime
function buildAndUpdateTempChart() {
$.getJSON('server/getReadings.php', function (data) {
$('#chartContainer').highcharts('StockChart', {
chart:{
events: {
load: function(){
// set up the updating of the chart each second
//debugger;
// var series = this.series[0];
// //console.log('data is: ' + data);
// for(var i = 0; i < 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'
},
xAxis: {
type: 'datetime'
},
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 = [];
for (var i = 0; i < data.length; i++) {
temp.push([
data[i].timestamp,
parseFloat(data[i].temp)
]);
}
return temp;
}()),
tooltip: {
valueDecimals: 2
}},
{
name: 'Ambient Temp',
data: (function () {
var aTemp = [];
for (var i = 0; i < data.length; i++) {
aTemp.push([
data[i].timestamp,
parseFloat(data[i].aTemp)
]);
}
return aTemp;
}()),
tooltip: {
valueDecimals: 2
},
}]
});
})
}
$(document).ready(function(){
buildAndUpdateTempChart(); //this is async so there rest of the app can continue to work
});
函数buildAndUpdateTempChart(){
$.getJSON('server/getReaders.php',函数(数据){
$(“#chartContainer”)。highcharts('StockChart'{
图表:{
活动:{
加载:函数(){
//设置图表的每秒更新
//调试器;
//var系列=本系列[0];
////console.log('数据为:'+数据);
//对于(var i=0;i