使用Flot我正在尝试开发一个图表,其中x轴以%M%D格式显示日期。但是,当运行以下代码时,它只会显示为纪元时间。
http://jsfiddle.net/unwo728s/1/
JavaScript代码:
var data = [ [gd(2016, 12, 3), 1000], [gd(2016, 12, 4), 200], [gd(2016, 12, 5), 3000], [gd(2016, 12, 6), 1000], [gd(2016, 12, 7), 1000], [gd(2016, 12, 8), 1000]];
var dataset = [
{
label: "Daily Amount",
data: data,
color: "#FFFFFF",
points: { fillColor: "#FFFFFF", show: true },
lines: { show: true }
}
];
var options = {
xaxes: {
mode: "time",
timeformat: "%m/%d",
tickSize: [3, "day"],
color: "black",
axisLabel: "Date",
}
};
$.plot($("#flot-placeholder"), dataset, options);
function gd(year, month, day) {
return new Date(year, month, day).getTime();
}
如何更改x轴以正确格式化?
答案 0 :(得分:0)