X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Faxis_labels-deprecated.js;h=da747e51a984707176e5973d364ac56d5fb8304f;hb=05f0c949e08dc94bb8cbaab4502a9e7c547c6d81;hp=2a8be09ac788efeb6576aae866551e31a86a3596;hpb=8021c59f150292bf1a12534e5092451140e49c77;p=dygraphs.git diff --git a/auto_tests/tests/axis_labels-deprecated.js b/auto_tests/tests/axis_labels-deprecated.js index 2a8be09..da747e5 100644 --- a/auto_tests/tests/axis_labels-deprecated.js +++ b/auto_tests/tests/axis_labels-deprecated.js @@ -22,16 +22,20 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDeprecatedXAxisTimeLabelFor var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); g.updateOptions({ - xAxisLabelFormatter: function (totalMinutes) { - var hours = Math.floor( totalMinutes / 60); - var minutes = Math.floor((totalMinutes - (hours * 60))); - var seconds = Math.round((totalMinutes * 60) - (hours * 3600) - (minutes * 60)); + axes : { + x : { + axisLabelFormatter: function (totalMinutes) { + var hours = Math.floor( totalMinutes / 60); + var minutes = Math.floor((totalMinutes - (hours * 60))); + var seconds = Math.round((totalMinutes * 60) - (hours * 3600) - (minutes * 60)); - if (hours < 10) hours = "0" + hours; - if (minutes < 10) minutes = "0" + minutes; - if (seconds < 10) seconds = "0" + seconds; + if (hours < 10) hours = "0" + hours; + if (minutes < 10) minutes = "0" + minutes; + if (seconds < 10) seconds = "0" + seconds; - return hours + ':' + minutes + ':' + seconds; + return hours + ':' + minutes + ':' + seconds; + } + } } }); @@ -46,19 +50,25 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedAxisLabelFormatter = functi var opts = { width: 480, height: 320, - xAxisLabelFormatter: function(x, granularity, opts, dg) { - assertEquals('number', typeof(x)); - assertEquals('number', typeof(granularity)); - assertEquals('function', typeof(opts)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + x; - }, - yAxisLabelFormatter: function(y, granularity, opts, dg) { - assertEquals('number', typeof(y)); - assertEquals('number', typeof(granularity)); - assertEquals('function', typeof(opts)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'y' + y; + axes : { + x : { + axisLabelFormatter: function(x, granularity, opts, dg) { + assertEquals('number', typeof(x)); + assertEquals('number', typeof(granularity)); + assertEquals('function', typeof(opts)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'x' + x; + } + }, + y : { + axisLabelFormatter: function(y, granularity, opts, dg) { + assertEquals('number', typeof(y)); + assertEquals('number', typeof(granularity)); + assertEquals('function', typeof(opts)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'y' + y; + } + } }, labels: ['x', 'y'] }; @@ -80,22 +90,26 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateAxisLabelFormatter = fu var opts = { width: 480, height: 320, - xAxisLabelFormatter: function(x, granularity, opts, dg) { - assertTrue(Dygraph.isDateLike(x)); - assertEquals('number', typeof(granularity)); - assertEquals('function', typeof(opts)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + Util.formatDate(x); - }, - yAxisLabelFormatter: function(y, granularity, opts, dg) { - assertEquals('number', typeof(y)); - assertEquals('number', typeof(granularity)); - assertEquals('function', typeof(opts)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'y' + y; - }, - axes: { - x: { pixelsPerLabel: 60 } + axes : { + x : { + axisLabelFormatter: function(x, granularity, opts, dg) { + assertTrue(Dygraph.isDateLike(x)); + assertEquals('number', typeof(granularity)); + assertEquals('function', typeof(opts)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'x' + Util.formatDate(x); + }, + pixelsPerLabel: 60 + }, + y : { + axisLabelFormatter: function(y, granularity, opts, dg) { + assertEquals('number', typeof(y)); + assertEquals('number', typeof(granularity)); + assertEquals('function', typeof(opts)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'y' + y; + } + } }, labels: ['x', 'y'] }; @@ -106,7 +120,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateAxisLabelFormatter = fu var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - assertEquals(["x2011/01/02"], Util.getXLabels()); + assertEquals(["x2011/01/02","x2011/01/04","x2011/01/06","x2011/01/08"], Util.getXLabels()); assertEquals(["y5","y10","y15"], Util.getYLabels()); g.setSelection(0); @@ -120,19 +134,25 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedValueFormatter = function ( var opts = { width: 480, height: 320, - xValueFormatter: function(x, opts, series_name, dg) { - assertEquals('number', typeof(x)); - assertEquals('function', typeof(opts)); - assertEquals('string', typeof(series_name)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + x; - }, - yValueFormatter: function(y, opts, series_name, dg) { - assertEquals('number', typeof(y)); - assertEquals('function', typeof(opts)); - assertEquals('string', typeof(series_name)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'y' + y; + axes : { + x : { + valueFormatter: function(x, opts, series_name, dg) { + assertEquals('number', typeof(x)); + assertEquals('function', typeof(opts)); + assertEquals('string', typeof(series_name)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'x' + x; + } + }, + y : { + valueFormatter: function(y, opts, series_name, dg) { + assertEquals('number', typeof(y)); + assertEquals('function', typeof(opts)); + assertEquals('string', typeof(series_name)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'y' + y; + } + } }, labels: ['x', 'y'] }; @@ -156,21 +176,27 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateValueFormatter = functi var opts = { width: 480, height: 320, - xValueFormatter: function(x, opts, series_name, dg) { - assertEquals('number', typeof(x)); - assertEquals('function', typeof(opts)); - assertEquals('string', typeof(series_name)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + Util.formatDate(x); + axes : { + x : { + valueFormatter: function(x, opts, series_name, dg) { + assertEquals('number', typeof(x)); + assertEquals('function', typeof(opts)); + assertEquals('string', typeof(series_name)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'x' + Util.formatDate(x); + }, + pixelsPerLabel: 60 + }, + y : { + valueFormatter: function(y, opts, series_name, dg) { + assertEquals('number', typeof(y)); + assertEquals('function', typeof(opts)); + assertEquals('string', typeof(series_name)); + assertEquals('[Dygraph graph]', dg.toString()); + return 'y' + y; + } + } }, - yValueFormatter: function(y, opts, series_name, dg) { - assertEquals('number', typeof(y)); - assertEquals('function', typeof(opts)); - assertEquals('string', typeof(series_name)); - assertEquals('[Dygraph graph]', dg.toString()); - return 'y' + y; - }, - axes: { x: { pixelsPerLabel: 60 } }, labels: ['x', 'y'] }; @@ -182,7 +208,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateValueFormatter = functi var g = new Dygraph(graph, data, opts); // valueFormatters do not affect ticks. - assertEquals(["02 Jan"], Util.getXLabels()); + assertEquals(["02 Jan","04 Jan","06 Jan","08 Jan"], Util.getXLabels()); assertEquals(["5","10","15"], Util.getYLabels()); // the valueFormatter options also affect the legend. @@ -196,17 +222,23 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedAxisLabelFormatterPrecedenc var opts = { width: 480, height: 320, - xValueFormatter: function(x) { - return 'xvf' + x; - }, - yValueFormatter: function(y) { - return 'yvf' + y; - }, - xAxisLabelFormatter: function(x, granularity) { - return 'x' + x; - }, - yAxisLabelFormatter: function(y) { - return 'y' + y; + axes : { + x : { + valueFormatter: function(x) { + return 'xvf' + x; + }, + axisLabelFormatter: function(x, granularity) { + return 'x' + x; + }, + }, + y : { + valueFormatter: function(y) { + return 'yvf' + y; + }, + axisLabelFormatter: function(y) { + return 'y' + y; + }, + } }, labels: ['x', 'y'] }; @@ -239,23 +271,39 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedAxisLabelFormatterIncrement var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); g.updateOptions({ - xValueFormatter: function(x) { - return 'xvf' + x; + axes : { + x : { + valueFormatter: function(x) { + return 'xvf' + x; + } + } } }); g.updateOptions({ - yValueFormatter: function(y) { - return 'yvf' + y; + axes : { + y : { + valueFormatter: function(y) { + return 'yvf' + y; + } + } } }); g.updateOptions({ - xAxisLabelFormatter: function(x, granularity) { - return 'x' + x; + axes : { + x : { + axisLabelFormatter: function(x) { + return 'x' + x; + } + } } }); g.updateOptions({ - yAxisLabelFormatter: function(y) { - return 'y' + y; + axes : { + y : { + axisLabelFormatter: function(y) { + return 'y' + y; + } + } } });