Flot 错误地解释时间戳:将不同的时间显示为相同的时间

Flot is interpreting timestamps incorrectly: displays different hours as same hour

我的图表上有以下几点:

data = [
            [1450825200, 3],
            [1450828800, 9],
            [1450832400, 8],
            [1450836000, 7],
            [1450839600, 6]
        ];

第一个值(data[0][0])是时间戳,第二个(data[0][1])是点击量。 根据 this converter,在我的时区 GMT+1:00,第一个 1450825200 等于当前日期和 12:00 AM,数组中的下一个时间戳(1450828800 ) 持有 1:00 PM,第三个 2:00 PM,等等

但是根据图表,我所有的时间戳都代表晚上 7 点。当我将鼠标悬停在点上时,每个点都显示 19:00 并且我的 x 轴消失了(因为 tickSize 设置为 1 小时并且没有其他时间)。

我正在以这种方式初始化图形:

$.plot('#graphDashboard', dataSet, // dataSet[0] contains data example I've shown above
        {
            plot: true,
            xaxes: [{
                mode: "time", timeformat: "%H:%M",
                tickSize: [1, "hour"]
            }],
            yaxes: [{
                position: 'left',
                tickFormatter: function (val, axis) {
                    return val.toLocaleString();
                }
            },
                {
                    position: 'left',
                    autoscaleMargin: 0.2,
                    tickFormatter: function (val, axis) {
                        return val.toLocaleString();
                    }
                }
            ],
            tooltipOpts: {
                content: "%s (%x, %y)",
                shifts: {
                    x: -100,
                    y: -50
                },
                dateFormat: "%H:%M",
                defaultTheme: false
            },
            series: {
                stack: false,
                lines: {
                    show: true,
                    fill: false
                }
            },
            legend: {
                show: false
            }
        });

Flot time plugin 基于 Javascript 时间戳。 Javascript 时间戳是自 1970 年 1 月 1 日 00:00:00 UTC 以来的 毫秒 数。您需要将时间戳(当前以秒为单位)乘以 1000 才能正确显示所有内容。