X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fx-axis-formatter.html;h=ef884e374e99b22fcaf1f0d402c6440cb2543a42;hb=2d0fdf6eb18eafde50830b8109f42e20b82247b1;hp=f4bfa36ed9204d47307b1a87eb8980ce76833dfe;hpb=54425b14df388e9337a1d77876512bb60ba74c3b;p=dygraphs.git diff --git a/tests/x-axis-formatter.html b/tests/x-axis-formatter.html index f4bfa36..ef884e3 100644 --- a/tests/x-axis-formatter.html +++ b/tests/x-axis-formatter.html @@ -2,13 +2,12 @@ X Axis Label Formatting - - - - - + + +

Original data:

@@ -32,33 +31,42 @@ "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; + } - new Dygraph( + var g1 = new Dygraph( document.getElementById("normal"), HourlyData() ); - new Dygraph( + var g2 = new Dygraph( document.getElementById("offby2"), HourlyData(), { - xAxisLabelFormatter: - function(d, gran) { - return Dygraph.dateAxisFormatter(new Date(d.getTime() + 7200*1000), gran); + axes: { + x: { + axisLabelFormatter: function(d, gran, opts) { + return Dygraph.dateAxisLabelFormatter(new Date(d.getTime() + 7200*1000), gran, opts); + } } + } }); - new Dygraph( + var g3 = new Dygraph( document.getElementById("seconds"), HourlyData(), { - xAxisLabelWidth: 70, - xAxisLabelFormatter: - function(d, gran) { - return Dygraph.zeropad(d.getHours()) + ":" - + Dygraph.zeropad(d.getMinutes()) + ":" - + Dygraph.zeropad(d.getSeconds()); + axes: { + x: { + axisLabelWidth: 70, + axisLabelFormatter: function(d, gran) { + return zeropad(d.getHours()) + ":" + + zeropad(d.getMinutes()) + ":" + + zeropad(d.getSeconds()); + } } + } });