Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery Flot未在x轴上显示正确的时间_Javascript_Jquery_Flot - Fatal编程技术网

Javascript JQuery Flot未在x轴上显示正确的时间

Javascript JQuery Flot未在x轴上显示正确的时间,javascript,jquery,flot,Javascript,Jquery,Flot,我的图表没有正确解析时间。x轴由unix时间戳组成,我的目标是在用户本地时间以M-D格式显示它。由于某些原因,所有日期都显示为01/18 JSFIDLE上的完整代码: 图形代码: var data = [[1492854610, -1240],[1492939020, -1273],[1493025073, -1279],[1493117066, -1186],[1493198484, -1269],[1493289175, 1198],[1493370646, -1280],[1493

我的图表没有正确解析时间。x轴由unix时间戳组成,我的目标是在用户本地时间以M-D格式显示它。由于某些原因,所有日期都显示为
01/18

JSFIDLE上的完整代码:

图形代码:

    var data = [[1492854610, -1240],[1492939020, -1273],[1493025073, -1279],[1493117066, -1186],[1493198484, -1269],[1493289175, 1198],[1493370646, -1280],[1493458518, -1255],[1493543731, -1275],[1493630250, -1273],[1493716306, -1279],[1493803609, -1264],[1493889258, -1276],[1493975557, -1278],[1494064529, -1235],[1494155440, -1160],[1494237980, -1224],[1494321047, -1280],[1494407990, -1271],[1494494125, -1275],[1494581609, -1257],[1494668321, -1252],[1494753220, -1277],[1494847855, -1140],[1494925963, -1278],[1495012537, -1275],[1495099289, -1269],[1495188205, -1227],[1495273568, -1244],[1495358329, -1272]];

    var ticks = [];
    var abovePoints = [];
    var belowPoints = [];

    for (var i = 0; i < data.length; i++) {
        ticks.push(data[i][0]);
    }

    data = [
        { label: null, data: data, points: {show:false} },
        { label: null, data: data, points: {show:true},  lines: {show:false}}
    ];

    $.plot('#placeholder', data, {
        grid: { 
        hoverable: true, 
        markings: [
            { color: '#000', lineWidth: 1, yaxis: { from: 0, to: 0 } },
                    ]          
        },
        series: {
            color: '#f36b6b',
            lines: {
                show: true,
                fill: true
            },
            points: {
                show: true
            },
            threshold: {
                below: 0,
                color: '#56af45'
            }
        },
        xaxis: {
               mode: "time",
               timeformat: "%m-%e"
        }
    });
var数据=[[1492854610,-1240],[1492939020,-1273],[1493025073,-1279],[1493117066,-1186],[1493198484,-1269],[14932891751198],[1493370646,-1280],[149345518,-1255],[1493543737331,-1275],[1493630250,-],[149316306,-1279],[14931803609],[1264],[149389258],[14935555557,-1275],[1493545945],[1493545],[14934045],[1494237980, -1224],[1494321047, -1280],[1494407990, -1271],[1494494125, -1275],[1494581609, -1257],[1494668321, -1252],[1494753220, -1277],[1494847855, -1140],[1494925963, -1278],[1495012537, -1275],[1495099289, -1269],[1495188205, -1227],[1495273568, -1244],[1495358329, -1272]];
var=[];
var高于点=[];
var低于点=[];
对于(变量i=0;i
JavaScript时间戳以毫秒为单位,而UNIX时间戳以秒为单位。您需要将时间戳乘以1000:

        var data = [[1492854610000, -1240],[1492939020000, -1273],[1493025073000, -1279],[1493117066000, -1186],[1493198484000, -1269],[1493289175000, 1198],[1493370646000, -1280],[1493458518000, -1255],[1493543731000, -1275],[1493630250000, -1273],[1493716306000, -1279],[1493803609000, -1264],[1493889258000, -1276],[1493975557000, -1278],[1494064529000, -1235],[1494155440000, -1160],[1494237980000, -1224],[1494321047000, -1280],[1494407990000, -1271],[1494494125000, -1275],[1494581609000, -1257],[1494668321000, -1252],[1494753220000, -1277],[1494847855000, -1140],[1494925963000, -1278],[1495012537000, -1275],[1495099289000, -1269],[1495188205000, -1227],[1495273568000, -1244],[1495358329000, -1272]];
有关更多信息,请参阅。更新的小提琴: