关于highchart【续】
额、、、 为什么连打酱油的都没。。。
这个fomatter 可以达到效果
formatter: function () {
if (this.value < parseInt(data.time[0][0].replace("/Date(", "").replace("+0800)/", ""), 10)) {
//按照比例获取数据源中的元素
var width = $("#container").width();//获取宽度
var a = Math.round(width / this.value);
var b = Math.round(data.time[0].length / a);
var c;
if (data.time[0][b] == undefined) {
c = ChangeDateFormat(data.time[0][data.time[0].length - 1]);
}
else {
c = ChangeDateFormat(data.time[0][b]);
}
date = c;
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var min = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var sec = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
c = date.getFullYear() + "-" + month + "-" + currentDate + "-" + hours + ":" + min + ":" + sec;
return c;
}
var date = new Date(this.value);
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var min = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var sec = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
var c = date.getFullYear() + "-" + month + "-" + currentDate + "-" + hours + ":" + min + ":" + sec;
return c;
},
