Flot X轴(无法输出日期)


Flot X axis (Cannot output date)

我正在尝试输出带有日期的x轴。我目前正在使用flot-api,我想在x轴刻度上输出一个像2012年3月xx日这样的日期。基本上,我会使用graph来推送日期。push[[tt,demand[I]];其中tt可以是2012年3月28日。然而,我的图并没有在我的轴上产生这个输出,而是产生-1到1的值。这是我推送日期的代码:

for (var i = 0; i <= y; i += 1) {
var splitdates = dates[i].split(" ");
var tt = splitdates[0]+"/"+splitdates[1]+"/"+splitdates[2];
graph.push([tt, demand[i]]);
}

这是我绘制x轴的代码:

var options = {
series: {
        lines: { show: true },
        points: { show: true }
        },
        grid: { hoverable: true, clickable: true },
        yaxis: { min: 0, max: 7000 },
        xaxis: {
        tickFormatter: function(value){
        return value;
        }
                             }

来自API船队:

Note that to simplify the internal logic in Flot both the x and y values must be numbers

如果你想要x轴上的字符串标签,你需要制作一个单独的"ticks"数组在api中搜索"Customizing the axis"部分。
演示

然而,在日期的情况下,flot具有本地支持,并且格式是可定制的。在api中搜索"时间序列数据"。
演示