我无法让当前日期和时间出现在图表的 x 轴上。到目前为止,它只是一个随机的日期和时间。价格在图表中正确加载,但日期和时间不正确。使用高图表。感谢任何帮助。
$(document).ready(function () {
$.ajax({
url: "/chart/ajax_get_chart", // the URL of the controller action method
dataType: "json",
type: "GET",
success: function (result) {
var result = JSON.parse(result);
var date = new Array();
var price = new Array();
var d = new Date();
series = [];
for (var i = 0; i < result.length; i++) {
tempArray = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
tempArray = parseFloat(result[i]['price']);
tempArray = [result[i]['date']*1000, parseFloat(result[i]['price'])];
series.push(tempArray);
}
console.log(tempArray);
// var now = new Date();
Highcharts.setOptions({
global: {
useUTC: false
}
});
$('#container').highcharts({
chart: {
type: 'line',
},
title: {
text: 'Bitcoin Price',
},
subtitle: {
text: 'Source: MtGox.com',
},
xAxis: {
type: 'datetime'
},
plotOptions: {
series: {
pointStart: d.getUTCDate()*1000,
pointInterval: 24 * 3600 * 1000 // one day
}
},
yAxis: {
title: {
text: 'Price'
},
},
series: [{
name: 'Bitcoin',
data: series
}]
});
}
});
});