flot display the date in flot based on timestamp

元气小坏坏 提交于 2019-11-28 09:18:43

I guess all you need to do is to multiply the timestamp (which look like unix timestamps) by 1000.

Unix timestamp tracks time as a running total of seconds starting from January 1st, 1970. While javascript timestamps measure milliseconds. So just multiply by 1000 and you should be fine

Try defining the 'timeformat' attribute, and define the pattern that flot will use to format the millisecond value.

xaxis:{
    mode: "time",
    timeformat: "%M:%S"
},

I use this:

    var options = {
    lines: { show: true },
    points: { show: true },
    xaxis: { mode: "time",  timeformat: "%m/%d/%y",   minTickSize: [1, "day"]}
};

I just ran into this and I think we both used the same bad Flot example. The signature is:

var plot = $.plot(placeholder, data, options)

And your code is doing something like

var plot = $.plot(placeholder, data, xoptions, yoptions)

So to fix it, just do this instead:

$.plot(
    $("#placeholder"), 
    [{data:d1,lines:{show: true},label:"Mountain"},{data:d2,lines:{show:true},label:"Valley"}],
    {yaxis: {label:"cm"}, xaxis: {mode:"time"}}
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!