1

Is there an easy way to display one digit months / dates with a leading (left padded) zero in the jQuery graph tool "flot" along the x-axis (version 0.7)?

xaxis: { mode: "time", timeformat: "%y-%m-%d/", TickSize: [1, "day"]}

gives for example 2012-9-5, which preferably should be 2012-09-05

More of the code....

<div id="placeholder" style="width:900px;height:200px;"></div>

<script>
$(function () {
    var d = [<?php echo $qforgraph; //[1203894000000, 288]
    ?>];

    var options = {
    lines: { show: true },
    points: { show: true },
    xaxis: { mode: "time", timeformat: "%y-%0-%0", minTickSize: [1, "month"]},
grid: { backgroundColor: { colors: ["#FFF", "#EEF"] }    }
};    
    var plot = $.plot($("#placeholder"), [d], options);
});
</script>
K. Kilian Lindberg
  • 2,918
  • 23
  • 30
  • 1
    %0d and %0m are suggested here http://stackoverflow.com/questions/2507235/jquery-flot-xaxis-time – naomi Feb 20 '13 at 16:53
  • Naomi that worked! If you could please repost that as an answer instead (now it's a comment) so i could check it as an "accepted answer", that would be great. :) – K. Kilian Lindberg Feb 22 '13 at 12:55

1 Answers1

0

Are you using version 0.7? Months and days are zero-padded by default in master.

DNS
  • 37,249
  • 18
  • 95
  • 132