X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fvalue-axis-formatters.html;h=f69c99da514376f2582eb76f2dc1ffe01a96738a;hb=f160e4ac8166f74d1f0e5604061564fbca5ba5a5;hp=193c48e2100a263bbab951d821ffbc9531f93d16;hpb=48e614acf3084b9836803f8b014bf0e65f1ca119;p=dygraphs.git diff --git a/tests/value-axis-formatters.html b/tests/value-axis-formatters.html index 193c48e..f69c99d 100644 --- a/tests/value-axis-formatters.html +++ b/tests/value-axis-formatters.html @@ -1,16 +1,9 @@ - + valueFormatter and axisLabelFormatter - - - + @@ -43,6 +36,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, @@ -50,24 +50,20 @@ labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], width: 640, height: 350, - 'Y3': { - axis: { - } + series: { + 'Y3': { axis: 'y2' }, + 'Y4': { axis: 'y2' } }, - 'Y4': { - axis: 'Y3' // use the same y-axis as series Y3 - }, - 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) { @@ -75,7 +71,8 @@ }, axisLabelFormatter: function(y) { return 'yalf(' + y.toPrecision(2) + ')'; - } + }, + axisLabelWidth: 100 }, y2: { valueFormatter: function(y2) {