jquery flot xaxis time

2020-02-04 07:46发布

In this example in xaxis will compare the days...

$.plot($("#placeholder"), data, {
                yaxis: {},
                xaxis: { mode: "time",minTickSize: [1, "day"],timeformat: "%d/%m/%y"},"lines": {"show": "true"},"points": {"show": "true"},clickable:true,hoverable: true
            });

How I can print time?

This is the result that I wanna:

22:00 23:00 00:00 01:00 02:00 ...... 23:00 00:00 01:00 02:00 .... 06:00

Is it possible?

标签: jquery flot
2条回答
狗以群分
2楼-- · 2020-02-04 07:52

From the Api Official Docs of Flot: (see https://github.com/flot/flot/blob/master/API.md)

  xaxis: {
    mode: "time",
    timeformat: "%y/%m/%d"
  }

This will result in tick labels like "2000/12/24". The following specifiers are supported

 %h: hours
  %H: hours (left-padded with a zero)
  %M: minutes (left-padded with a zero)
  %S: seconds (left-padded with a zero)
  %d: day of month (1-31), use %0d for zero-padding
  %m: month (1-12), use %0m for zero-padding
  %y: year (2 digits)
  %Y: year (4 digits)
  %b: month name (customizable)
  %p: am/pm, additionally switches %h/%H to 12 hour instead of 24
  %P: AM/PM (uppercase version of %p)
查看更多
唯我独甜
3楼-- · 2020-02-04 08:08
$.plot($("#placeholder"), data, {
        yaxis: {
        },
        xaxis: { mode: "time",minTickSize: [1, "hour"],
                min: (new Date("2000/01/01")).getTime(),
                max: (new Date("2000/01/02")).getTime()
},
        "lines": {"show": "true"},
        "points": {"show": "true"},
        clickable:true,hoverable: true
});

use this as a starting point and you can see the result here http://jsfiddle.net/UEePE/

查看更多
登录 后发表回答