X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Ferror_bars.js;h=e57898be27a01190d50de893059bfe256c6c49f8;hb=0b4cf8f0eefb5c3c8592843474843d57cc0494f2;hp=c9e3a387baf2e2d2c7adbde18781fd39cf0cf966;hpb=6278f6fe69767cf21c1d3361bc141321a282d9ef;p=dygraphs.git diff --git a/auto_tests/tests/error_bars.js b/auto_tests/tests/error_bars.js index c9e3a38..e57898b 100644 --- a/auto_tests/tests/error_bars.js +++ b/auto_tests/tests/error_bars.js @@ -9,16 +9,16 @@ errorBarsTestCase.prototype.setUp = function() { document.body.innerHTML = "
"; }; -var _origFunc = Dygraph.getContext; +errorBarsTestCase._origFunc = Dygraph.getContext; errorBarsTestCase.prototype.setUp = function() { document.body.innerHTML = "
"; Dygraph.getContext = function(canvas) { - return new Proxy(_origFunc(canvas)); + return new Proxy(errorBarsTestCase._origFunc(canvas)); } }; errorBarsTestCase.prototype.tearDown = function() { - Dygraph.getContext = _origFunc; + Dygraph.getContext = errorBarsTestCase._origFunc; }; errorBarsTestCase.prototype.testErrorBarsDrawn = function() { @@ -89,3 +89,43 @@ errorBarsTestCase.prototype.testErrorBarsDrawn = function() { CanvasAssertions.assertBalancedSaveRestore(htx); }; +errorBarsTestCase.prototype.testErrorBarsCorrectColors = function() { + // Two constant series with constant error. + var data = [ + [0, [100, 50], [200, 50]], + [1, [100, 50], [200, 50]] + ]; + + var opts = { + errorBars: true, + sigma: 1.0, + fillAlpha: 0.15, + colors: ['#00ff00', '#0000ff'], + drawXGrid: false, + drawYGrid: false, + drawXAxis: false, + drawYAxis: false, + width: 400, + height: 300, + valueRange: [0, 300], + labels: ['X', 'Y1', 'Y2'] + }; + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, data, opts); + + // y-pixels (0=top, 299=bottom) + // 0- 48: empty (white) + // 49- 98: Y2 error bar + // 99: Y2 center line + // 100-148: Y2 error bar + // 149-198: Y1 error bar + // 199: Y1 center line + // 200-248: Y1 error bar + // 249-299: empty (white) + // TODO(danvk): test the edges of these regions. + + assertEquals([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 75)); + assertEquals([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 125)); + assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 175)); + assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 225)); +}