From 17bdb194d3ff6ecc02224038b3070024a5949e97 Mon Sep 17 00:00:00 2001 From: "Thomas J. Lynch" Date: Wed, 27 May 2015 18:43:50 -0400 Subject: [PATCH] Added test cases to verify that per series alphaFill is working properly --- auto_tests/tests/per_series.js | 43 +++++++++++++++++++++++ tests/fillGraph-alpha.html | 77 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 tests/fillGraph-alpha.html diff --git a/auto_tests/tests/per_series.js b/auto_tests/tests/per_series.js index a09f912..07af084 100644 --- a/auto_tests/tests/per_series.js +++ b/auto_tests/tests/per_series.js @@ -55,6 +55,49 @@ it('testPerSeriesFill', function() { assert.deepEqual([255,0,0,38], sampler.colorAtCoordinate(6.5, 0.5)); }); +it('testPerSeriesAlpha', function() { + var opts = { + width: 480, + height: 320, + axes : { + x : { + drawGrid: false, + drawAxis: false, + }, + y : { + drawGrid: false, + drawAxis: false, + } + }, + series: { + Y: { fillGraph: true, fillAlpha: 0.25 }, + Z: { fillGraph: true, fillAlpha: 0.75 } + }, + colors: [ '#FF0000', '#0000FF' ] + }; + var data = "X,Y,Z\n" + + "1,0,0\n" + + "2,0,1\n" + + "3,0,1\n" + + "4,0,0\n" + + "5,0,0\n" + + "6,1,0\n" + + "7,1,0\n" + + "8,0,0\n" + ; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, data, opts); + + var sampler = new PixelSampler(g); + + // Inside of the "Y" bump -- 5% alpha. + assert.deepEqual([255,0,0,63], sampler.colorAtCoordinate(6.5, 0.5)); + + // Inside of the "Z" bump -- 95% alpha. + assert.deepEqual([0,0,255,191], sampler.colorAtCoordinate(2.5, 0.5)); +}); + it('testNewStyleSeries', function() { var opts = { pointSize : 5, diff --git a/tests/fillGraph-alpha.html b/tests/fillGraph-alpha.html new file mode 100644 index 0000000..6d180ce --- /dev/null +++ b/tests/fillGraph-alpha.html @@ -0,0 +1,77 @@ + + + + fillGraph with per series fillAlpha + + + + + +

Filled, using default value

+
+ +

Filled, using global alpha value

+
+ +

Filled, using per series alpha values

+
+ +

Filled, using a mix of global and per series values

+
+ + + + -- 2.7.4