不正确显示时间戳/日期

时间:2013-04-12 21:03:31

标签: javascript flot

情节图不能正确显示日期/小时。在x轴上有unix时间戳的值。

数据:

 [[1365712202000,61.39],[1365712510000,60.89],[1365712817000,0]]

flot configs:

    $.plot(plotarea , [
        {
            label: "Value",
            data: dataLine,
            color: "#FF8848",
            lines: { show: true, steps: false },
            points: { show: true },
            grid: { hoverable: true, clickable: true },
            xaxis: { mode: "time", timeformat: "%d/%H/%M" }
        }
    ]

enter image description here

1 个答案:

答案 0 :(得分:2)

您的配置错误。 xaxisgrid不是系列选项,而是绘图选项。尝试:

$.plot($('#placeholder') ,[{
        label: "Value",
        data: dataLine,
        color: "#FF8848",
        lines: { show: true, steps: false },
        points: { show: true }            
    }],
    {
       grid: { hoverable: true, clickable: true },
       xaxis: { mode: "time", timeformat: "%d/%H/%M" }
    }
);

小提琴here