2010-03-24 9 views
18

In diesem Beispiel in xaxis werden die Tage vergleichen ...jquery flicht xaxis Zeit

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

Wie ich Zeit drucken kann?

Dies ist das Ergebnis, das ich will:

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

Ist es möglich?

Antwort

20
$.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 
}); 

diese Verwendung als Ausgangspunkt und Sie können http://jsfiddle.net/UEePE/

55

Vom Api offiziellen Dokumente von Flot das Ergebnis hier sehen: (siehe https://github.com/flot/flot/blob/master/API.md)

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

Diese in Strichbeschriftungen führen wie "2000/12/24". Die folgenden Spezifizierer

unterstützt
%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) 
+6

SUPER NIT PICK, werden Sie ein Komma wollen nach „Zeit“. – rnalexander

+7

Ich bin mir ziemlich sicher, dass das Einfangen eines Exception-Wurf-Fehlers nicht super ist. – Bobby

+0

reparierte meine Antwort – MaTriXy

Verwandte Themen