X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fx-axis-formatter.html;h=3f8f01ce87b89b757d94614c5921b25431e0c84a;hb=a5f3d82dc74669f378a1e7c63e10bd9804ce4ca2;hp=a2f78270a9fa83c343ee0929a01e43a9a43a3523;hpb=fbd6834a9de994c68825a17fdaae2eaf514227ae;p=dygraphs.git diff --git a/tests/x-axis-formatter.html b/tests/x-axis-formatter.html index a2f7827..3f8f01c 100644 --- a/tests/x-axis-formatter.html +++ b/tests/x-axis-formatter.html @@ -1,11 +1,8 @@ + X Axis Label Formatting - @@ -31,6 +28,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 +54,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()); } } }