X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fx-axis-formatter.html;h=63b9e053ebc6eecfb11ad2cfedd1cfcac1829eda;hb=660bb307f01c14f7d7d1b839812840fb179481ec;hp=90b08ce1a4abec825b9e2d9b1df15b38b3396c85;hpb=2cfce1c8103454bca196e57db3f23272b7ee5b6e;p=dygraphs.git diff --git a/tests/x-axis-formatter.html b/tests/x-axis-formatter.html index 90b08ce..63b9e05 100644 --- a/tests/x-axis-formatter.html +++ b/tests/x-axis-formatter.html @@ -1,12 +1,13 @@ + X Axis Label Formatting - + @@ -31,6 +32,9 @@ "2009/07/12 05:00:00,3,6\n" + "2009/07/12 06:00:00,4,6" } + function zeropad(x) { + return (x < 10) ? '0' + x : x; + } var g1 = new Dygraph( document.getElementById("normal"), @@ -54,13 +58,13 @@ document.getElementById("seconds"), HourlyData(), { - xAxisLabelWidth: 70, axes: { x: { + axisLabelWidth: 70, axisLabelFormatter: function(d, gran) { - return Dygraph.zeropad(d.getHours()) + ":" - + Dygraph.zeropad(d.getMinutes()) + ":" - + Dygraph.zeropad(d.getSeconds()); + return zeropad(d.getHours()) + ":" + + zeropad(d.getMinutes()) + ":" + + zeropad(d.getSeconds()); } } }