From 289e5e9974aad1a596fa2065f15f45bdc2f14cbb Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Thu, 15 Nov 2012 18:22:39 -0600 Subject: [PATCH] Add tests (which currently fail) that ensure that drawPointCallback and drawHighlightPointCallback play nice with axis settings. --- auto_tests/tests/multiple_axes.js | 80 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/auto_tests/tests/multiple_axes.js b/auto_tests/tests/multiple_axes.js index 05e93c7..3644e65 100644 --- a/auto_tests/tests/multiple_axes.js +++ b/auto_tests/tests/multiple_axes.js @@ -290,4 +290,82 @@ MultipleAxesTestCase.prototype.testValueRangePerAxisOptions = function() { ); assertEquals(["40", "45", "50", "55", "60", "65", "70", "75"], getYLabelsForAxis("1")); assertEquals(["1M", "1.02M", "1.05M", "1.08M", "1.1M", "1.13M", "1.15M", "1.18M"], getYLabelsForAxis("2")); -}; \ No newline at end of file +}; + +MultipleAxesTestCase.prototype.testDrawPointCallback = function() { + var data = MultipleAxesTestCase.getData(); + + var results = { y : {}, y2 : {}}; + var firstCallback = function(g, seriesName) { + results.y[seriesName] = 1; + }; + var secondCallback = function(g, seriesName) { + results.y2[seriesName] = 1; + }; + + g = new Dygraph( + document.getElementById("graph"), + data, + { + labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], + drawPoints : true, + 'Y3': { + axis: { + } + }, + 'Y4': { + axis: 'Y3' // use the same y-axis as series Y3 + }, + axes: { + y2: { + drawPointCallback: secondCallback + } + }, + drawPointCallback: firstCallback + } + ); + + assertEquals(1, results.y["Y1"]); + assertEquals(1, results.y["Y2"]); + assertEquals(1, results.y2["Y3"]); + assertEquals(1, results.y2["Y4"]); +}; + +MultipleAxesTestCase.prototype.testDrawHighlightPointCallback = function() { + var data = MultipleAxesTestCase.getData(); + + var results = { y : {}, y2 : {}}; + var firstCallback = function(g, seriesName) { + results.y[seriesName] = 1; + }; + var secondCallback = function(g, seriesName) { + results.y2[seriesName] = 1; + }; + + g = new Dygraph( + document.getElementById("graph"), + data, + { + labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], + drawPoints : true, + 'Y3': { + axis: { + } + }, + 'Y4': { + axis: 'Y3' // use the same y-axis as series Y3 + }, + axes: { + y2: { + drawHighlightPointCallback: secondCallback + } + }, + drawHighlightPointCallback: firstCallback + } + ); + + assertEquals(1, results.y["Y1"]); + assertEquals(1, results.y["Y2"]); + assertEquals(1, results.y2["Y3"]); + assertEquals(1, results.y2["Y4"]); +}; -- 2.7.4