X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fupdate_options.js;h=ac28e99b2abc38fe5670e26cac8c11ef31f81325;hb=e26b71566419e1c051f3fbd1f4f8f64b063a04c9;hp=b40d705d06bb9b2c912205e20e79edfde2ef70aa;hpb=b455a0ef684db54cec99802170857a0281effedd;p=dygraphs.git diff --git a/auto_tests/tests/update_options.js b/auto_tests/tests/update_options.js index b40d705..ac28e99 100644 --- a/auto_tests/tests/update_options.js +++ b/auto_tests/tests/update_options.js @@ -136,11 +136,39 @@ UpdateOptionsTestCase.prototype.testUpdateColors = function() { graph.updateOptions({ colors: colors1 }); assertEquals(colors1, graph.getColors()); - var colors2 = [ "#aaa", "#bbb", "#ccc" ]; + // extra colors are ignored until you add additional data series. + var colors2 = [ "#ddd", "#eee", "#fff" ]; graph.updateOptions({ colors: colors2 }); - assertEquals(colors2, graph.getColors()); + assertEquals(["#ddd", "#eee"], graph.getColors()); + graph.updateOptions({ file: + "X,Y1,Y2,Y3\n" + + "2011-01-01,2,3,4\n" + + "2011-02-02,5,3,2\n" + }); + assertEquals(colors2, graph.getColors()); - graph.updateOptions({ colors: null }); + graph.updateOptions({ colors: null, file: this.data }); assertEquals(defaultColors, graph.getColors()); } + +// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=249 +// Verifies that setting 'legend: always' via update immediately shows the +// legend. +UpdateOptionsTestCase.prototype.testUpdateLegendAlways = function() { + var graphDiv = document.getElementById("graph"); + var graph = new Dygraph(graphDiv, this.data, this.opts); + + var legend = document.getElementsByClassName("dygraph-legend"); + assertEquals(1, legend.length); + legend = legend[0]; + assertEquals("", legend.innerHTML); + + graph.updateOptions({legend: 'always'}); + + legend = document.getElementsByClassName("dygraph-legend"); + assertEquals(1, legend.length); + legend = legend[0]; + assertNotEquals(-1, legend.textContent.indexOf("Y1")); + assertNotEquals(-1, legend.textContent.indexOf("Y2")); +};