X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fvalue-axis-formatters.html;h=caffab48a38f292d8e38a50d4334eb7738f47809;hb=0bc4cb546af5d1ce157ad701a45169cc07c9c839;hp=184101e72da4b37cc56d0c952e536e452ef50df7;hpb=15c1e309939d7e3a5eb363f84547c1efd336c365;p=dygraphs.git diff --git a/tests/value-axis-formatters.html b/tests/value-axis-formatters.html index 184101e..caffab4 100644 --- a/tests/value-axis-formatters.html +++ b/tests/value-axis-formatters.html @@ -1,16 +1,13 @@ - + valueFormatter and axisLabelFormatter - - + @@ -43,6 +40,13 @@ 1e6 * (2 - i * (100 - i) / (50 * 50))]); } + function formatDate(d) { + var yyyy = d.getFullYear(), + mm = d.getMonth() + 1, + dd = d.getDate(); + return yyyy + '-' + (mm < 10 ? '0' : '') + mm + (dd < 10 ? '0' : '') + dd; + } + g = new Dygraph( document.getElementById("demodiv"), data, @@ -54,17 +58,16 @@ 'Y3': { axis: 'y2' }, 'Y4': { axis: 'y2' } }, - xAxisLabelWidth: 100, - yAxisLabelWidth: 100, axes: { x: { valueFormatter: function(ms) { - return 'xvf(' + new Date(ms).strftime('%Y-%m-%d') + ')'; + return 'xvf(' + formatDate(new Date(ms)) + ')'; }, axisLabelFormatter: function(d) { - return 'xalf(' + d.strftime('%Y-%m-%d') + ')'; + return 'xalf(' + formatDate(d) + ')'; }, pixelsPerLabel: 100, + axisLabelWidth: 100, }, y: { valueFormatter: function(y) { @@ -72,7 +75,8 @@ }, axisLabelFormatter: function(y) { return 'yalf(' + y.toPrecision(2) + ')'; - } + }, + axisLabelWidth: 100 }, y2: { valueFormatter: function(y2) {