Flot 显示时间戳中的日期不正确

Flot displaying dates from timestamps incorrect

这是我在 Flot 上的 x 轴上的内容。以下不是拼写错误,它是格式正确的重复日期,但完全错误。

例如1262188800.0 == 2009 年 12 月 31 日

弗洛特为什么要这样做?

1970/01/15 1970/01/15 1970/01/16 1970/01/16 1970/01/16 1970/01/16 1970/01/16


tsPlot(data_ts){

        let dataset = [
            {
                label: "Mean",
                data: data_ts["mean_1"],
                points: { fillColor: "#FF0000", show: true },
                lines: { show: true }
            },
            {
                label: "Var",
                data: data_ts["var_1"],
                points: { fillColor: "#FF0000", show: true },
                lines: { show: true }
            }
        ];



        let options = {
            grid: { hoverable: true, clickable: true },
            xaxis: { mode: "time",
                     timeformat: "%Y/%m/%d" 
                    }
        };
        this.plot = $.plot($("#placeholder_ts"),dataset,options);
        this.plot.setupGrid();
        this.plot.draw();

    }

    data_ts = { "mean_1": [
        [1262188800.0, 500],
        [1264867200.0, 500],
        [1267286400.0, 500],
        [1269964800.0, 492],
        [1272556800.0, 484],
        [1275235200.0, 484],
        [1277827200.0, 477],
        [1280505600.0, 477],
        [1283184000.0, 470],
        [1285776000.0, 475],
        [1288454400.0, 471],
        [1291046400.0, 480],
        [1293724800.0, 480],
        [1296403200.0, 489],
        [1298822400.0, 489],
        [1301500800.0, 489],
        [1304092800.0, 490],
        [1306771200.0, 500],
        [1309363200.0, 500],
        [1312041600.0, 500],
        [1314720000.0, 500],
        [1317312000.0, 490],
        [1319990400.0, 484],
        [1322582400.0, 492],
        [1325260800.0, 492],
        [1327939200.0, 488],
        [1330444800.0, 498],
        [1333123200.0, 498],
        [1335715200.0, 499],
        [1338393600.0, 493],
        [1340985600.0, 485],
        [1343664000.0, 493],
        [1346342400.0, 493],
        [1348934400.0, 493],
        [1351612800.0, 498],
        [1354204800.0, 498],
        [1356883200.0, 506],
        [1359561600.0, 510],
        [1361980800.0, 510],
        [1364659200.0, 510],
        [1367251200.0, 514],
        [1369929600.0, 516],
        [1372521600.0, 516],
        [1375200000.0, 513],
        [1377878400.0, 513],
        [1380470400.0, 517],
        [1383148800.0, 517]
    ],
    "var_1": [
        [1262188800.0, 300],
        [1264867200.0, 300],
        [1267286400.0, 300],
        [1269964800.0, 292],
        [1272556800.0, 284],
        [1275235200.0, 284],
        [1277827200.0, 277],
        [1280505600.0, 277],
        [1283184000.0, 270],
        [1285776000.0, 275],
        [1288454400.0, 271],
        [1291046400.0, 280],
        [1293724800.0, 280],
        [1296403200.0, 289],
        [1298822400.0, 289],
        [1301500800.0, 289],
        [1304092800.0, 290],
        [1306771200.0, 300],
        [1309363200.0, 300],
        [1312041600.0, 300],
        [1314720000.0, 300],
        [1317312000.0, 290],
        [1319990400.0, 284],
        [1322582400.0, 292],
        [1325260800.0, 292],
        [1327939200.0, 288],
        [1330444800.0, 298],
        [1333123200.0, 298],
        [1335715200.0, 299],
        [1338393600.0, 293],
        [1340985600.0, 285],
        [1343664000.0, 293],
        [1346342400.0, 293],
        [1348934400.0, 293],
        [1351612800.0, 298],
        [1354204800.0, 298],
        [1356883200.0, 306],
        [1359561600.0, 310],
        [1361980800.0, 310],
        [1364659200.0, 310],
        [1367251200.0, 314],
        [1369929600.0, 316],
        [1372521600.0, 316],
        [1375200000.0, 313],
        [1377878400.0, 313],
        [1380470400.0, 317],
        [1383148800.0, 317]
    ]
}

Flot 是正确的,你的时间戳是错误的,见documentation:

The time series support in Flot is based on Javascript timestamps, i.e. everywhere a time value is expected or handed over, a Javascript timestamp number is used. This is a number, not a Date object. A Javascript timestamp is the number of milliseconds since January 1, 1970 00:00:00 UTC. This is almost the same as Unix timestamps, except it's in milliseconds, so remember to multiply by 1000!