2016-06-21 3 views
0

flot을 사용하여 x 축에 표시 할 m/d/y 형식으로 타임 스탬프를 가져 오려고합니다. API docs을 읽었지만 타임 스탬프가 변환되지 않습니다. 내가 어디로 잘못 갔니?JQuery Flot 타임 스탬프

<!-- Flot demo info --> 
    <script> 
      $(document).ready(function() { 
      //random data 
      var d1 = [ 
       [(new Date(2016, 6, 23)).getTime(), 55], 
       [(new Date(2016, 6, 24)).getTime(), 45], 
       [(new Date(2016, 6, 25)).getTime(), 55], 
       [(new Date(2016, 6, 26)).getTime(), 65], 
       [(new Date(2016, 6, 27)).getTime(), 25], 
       [(new Date(2016, 6, 28)).getTime(), 85], 
       [(new Date(2016, 6, 29)).getTime(), 15], 
      ]; 

      //flot options 
      var options = { 
       series: { 
       curvedLines: { 
        apply: true, 
        active: true, 
        monotonicFit: true 
       } 
       }, 
       colors: ["#26B99A"], 
       grid: { 
       borderWidth: { 
        top: 0, 
        right: 0, 
        bottom: 1, 
        left: 1 
       }, 
       borderColor: { 
        bottom: "#7F8790", 
        left: "#7F8790" 
       } 
       } 
      }; 
      var plot = $.plot($("#security_activity"), [{ 
       label: "Security", 
       data: d1, 
       yaxis: {}, 
       xaxis: { 
       mode: "time", 
       timeformat: "%m/%d/%y" 
       }, 
       lines: { 
       fillColor: "rgba(150, 202, 89, 0.12)" 
       }, //#96CA59 rgba(150, 202, 89, 0.42) 
       points: { 
       fillColor: "#fff" 
       } 
      }], options); 
      }); 
     </script> 

답변

0

flot graph

은 헉, 저 바보 ... X- 축이/잘못된 자리에서 옵션을 y 축했다.

업데이트 코드 :

<!-- Flot demo info --> 
    <script> 
      $(document).ready(function() { 
      //random data 
      var d1 = [ 
       [(new Date(2016, 6, 23)).getTime(), 55], 
       [(new Date(2016, 6, 24)).getTime(), 45], 
       [(new Date(2016, 6, 25)).getTime(), 55], 
       [(new Date(2016, 6, 26)).getTime(), 65], 
       [(new Date(2016, 6, 27)).getTime(), 25], 
       [(new Date(2016, 6, 28)).getTime(), 85], 
       [(new Date(2016, 6, 29)).getTime(), 15] 
      ]; 

      //flot options 
      var options = { 
       series: { 
       curvedLines: { 
        apply: true, 
        active: true, 
        monotonicFit: true 
       } 
       }, 
       colors: ["#26B99A"], 
       grid: { 
       borderWidth: { 
        top: 0, 
        right: 0, 
        bottom: 1, 
        left: 1 
       }, 
       borderColor: { 
        bottom: "#7F8790", 
        left: "#7F8790" 
       } 
       }, 
       yaxis: {}, 
       xaxis: { 
       mode: "time", 
       timeformat: "%m/%d/%y", 
       minTickSize: [1, "day"] 
       } 
      }; 
      var plot = $.plot($("#security_activity"), [{ 
       label: "Security", 
       data: d1, 
       lines: { 
       fillColor: "rgba(150, 202, 89, 0.12)" 
       }, //#96CA59 rgba(150, 202, 89, 0.42) 
       points: { 
       fillColor: "#fff" 
       } 
      }], options); 
      }); 
     </script>