X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fx-axis-formatter.html;h=3f8f01ce87b89b757d94614c5921b25431e0c84a;hb=a5f3d82dc74669f378a1e7c63e10bd9804ce4ca2;hp=29cdd828aa755057a2fad5a1f22fe58cab19c7f0;hpb=a2b2c3a13b968bf10c9dbea58683b0f51011b547;p=dygraphs.git diff --git a/tests/x-axis-formatter.html b/tests/x-axis-formatter.html index 29cdd82..3f8f01c 100644 --- a/tests/x-axis-formatter.html +++ b/tests/x-axis-formatter.html @@ -1,13 +1,10 @@ + + X Axis Label Formatting - - - - - + +

Original data:

@@ -31,33 +28,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()); + } } + } });