X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fstacked.js;h=706f56fd2da6a51517a41bc5a18333b8d7336103;hb=34ad56b341279a066dc8bad129501d8d254699c1;hp=d2ecb193529c994a284984a5a9d58761627ef7f9;hpb=2b43177b643943d2632500cb49bb7b8631e91eff;p=dygraphs.git diff --git a/auto_tests/tests/stacked.js b/auto_tests/tests/stacked.js index d2ecb19..706f56f 100644 --- a/auto_tests/tests/stacked.js +++ b/auto_tests/tests/stacked.js @@ -41,8 +41,9 @@ stackedTestCase.prototype.testCorrectColors = function() { // y pixel 100 = y1 line (green) // y pixels 0-99 = nothing (white) - var canvas = g.hidden_ctx_; - var imageData = canvas.getImageData(0, 0, 400, 300); + // TODO(danvk): factor this and getPixel() into a utility usable by all tests. + var ctx = g.hidden_ctx_; + var imageData = ctx.getImageData(0, 0, 400, 300); assertEquals(400, imageData.width); assertEquals(300, imageData.height); @@ -58,5 +59,38 @@ stackedTestCase.prototype.testCorrectColors = function() { // 38 = round(0.15 * 255) assertEquals([0, 0, 255, 38], getPixel(imageData, 200, 250)); assertEquals([0, 255, 0, 38], getPixel(imageData, 200, 150)); - assertEquals([255, 255, 255, 255], getPixel(imageData, 200, 50)); +}; + +// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=358 +stackedTestCase.prototype.testSelectionValues = function() { + var opts = { + stackedGraph: true + }; + var data = "X,Y1,Y2\n" + + "0,1,1\n" + + "1,1,1\n" + + "2,1,1\n" + + "3,1,1\n" + ; + + var graph = document.getElementById("graph"); + g = new Dygraph(graph, data, opts); + + g.setSelection(0); + + assertEquals("0: Y1: 1 Y2: 1", Util.getLegend()); + + // Verify that the behavior is correct with highlightSeriesOpts as well. + g.updateOptions({ + highlightSeriesOpts: { + strokeWidth: 10 + } + }); + // NOTE: calling g.setSelection(0) here makes the test fail, due to an + // unrelated bug. + g.setSelection(1); + assertEquals("1: Y1: 1 Y2: 1", Util.getLegend()); + + g.setSelection(0, 'Y2'); + assertEquals("0: Y1: 1 Y2: 1", Util.getLegend()); };