X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=auto_tests%2Ftests%2Fmultiple_axes.js;h=ed9b3628ba553b5275d09ac85535ff548aef0045;hb=4a0cb9c4671b5c212da6ebc71e25fb9d1aaec692;hp=829e9968127df61572693ff5f8049b458c9df41c;hpb=48e614acf3084b9836803f8b014bf0e65f1ca119;p=dygraphs.git diff --git a/auto_tests/tests/multiple_axes.js b/auto_tests/tests/multiple_axes.js index 829e996..ed9b362 100644 --- a/auto_tests/tests/multiple_axes.js +++ b/auto_tests/tests/multiple_axes.js @@ -95,3 +95,75 @@ MultipleAxesTestCase.prototype.testNewStylePerAxisOptions = function() { assertEquals(["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"], getYLabelsForAxis("1")); assertEquals(["900K", "1.01M", "1.12M", "1.23M", "1.34M", "1.45M", "1.55M", "1.66M", "1.77M", "1.88M", "1.99M"], getYLabelsForAxis("2")); }; + +MultipleAxesTestCase.prototype.testMultiAxisLayout = function() { + var data = MultipleAxesTestCase.getData(); + + var el = document.getElementById("graph"); + + g = new Dygraph( + el, + data, + { + labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], + width: 640, + height: 350, + 'Y3': { + axis: { } + }, + 'Y4': { + axis: 'Y3' // use the same y-axis as series Y3 + }, + axes: { + y2: { + labelsKMB: true + } + } + } + ); + + // Test that all elements are inside the bounds of the graph, set above + var innerDiv = el.firstChild; + for (var child = innerDiv.firstChild; child != null; child = child.nextSibling) { + assertTrue(child.offsetLeft >= 0); + assertTrue((child.offsetLeft + child.offsetWidth) <= 640); + assertTrue(child.offsetTop >= 0); + // TODO(flooey@google.com): Text sometimes linebreaks, + // causing the labels to appear outside the allocated area. + // assertTrue((child.offsetTop + child.offsetHeight) <= 350); + } +}; + +MultipleAxesTestCase.prototype.testTwoAxisVisibility = function() { + var data = []; + data.push([0,0,0]); + data.push([1,2,2000]); + data.push([2,4,1000]); + + var g = new Dygraph( + document.getElementById("graph"), + data, + { + labels: [ 'X', 'bar', 'zot' ], + 'zot': { + axis: { + labelsKMB: true + } + } + } + ); + + assertTrue(document.getElementsByClassName("dygraph-axis-label-y").length > 0); + assertTrue(document.getElementsByClassName("dygraph-axis-label-y2").length > 0); + + g.setVisibility(0, false); + + assertTrue(document.getElementsByClassName("dygraph-axis-label-y").length > 0); + assertTrue(document.getElementsByClassName("dygraph-axis-label-y2").length > 0); + + g.setVisibility(0, true); + g.setVisibility(1, false); + + assertTrue(document.getElementsByClassName("dygraph-axis-label-y").length > 0); + assertTrue(document.getElementsByClassName("dygraph-axis-label-y2").length > 0); +};