From 6833c463ec383edd9dd4051b7a4cb8de834e27d0 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Tue, 27 Oct 2015 09:37:45 -0400 Subject: [PATCH] Update to ES6 modules --- auto_tests/tests/highlight_series_background.js | 28 ++++++++++++------------- src/dygraph.js | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/auto_tests/tests/highlight_series_background.js b/auto_tests/tests/highlight_series_background.js index aedc8ed..60f4f8d 100644 --- a/auto_tests/tests/highlight_series_background.js +++ b/auto_tests/tests/highlight_series_background.js @@ -1,18 +1,19 @@ /** - * @fileoverview Tests for the highlightSeriesBackgroundAlpha and highlightSeriesBackgroundColor options. + * @fileoverview Tests for the highlightSeriesBackgroundAlpha and + * highlightSeriesBackgroundColor options. * @author sergeyslepian@gmail.com */ -describe("highlight-series-background", function() { +import Dygraph from '../../src/dygraph'; +import * as utils from '../../src/dygraph-utils'; +import Util from './Util'; - beforeEach(function () { - document.body.innerHTML = "
"; - }); +describe("highlight-series-background", function() { - afterEach(function () { - }); + cleanupAfterEach(); - function setupGraph(highlightSeriesBackgroundAlpha, highlightSeriesBackgroundColor) { + function setupGraph(highlightSeriesBackgroundAlpha, + highlightSeriesBackgroundColor) { var opts = { width: 480, height: 320, @@ -25,16 +26,15 @@ describe("highlight-series-background", function() { } }; - if(highlightSeriesBackgroundAlpha !== undefined) opts.highlightSeriesBackgroundAlpha = highlightSeriesBackgroundAlpha; - if(highlightSeriesBackgroundColor !== undefined) opts.highlightSeriesBackgroundColor = highlightSeriesBackgroundColor; + if (highlightSeriesBackgroundAlpha) utils.update(opts, {highlightSeriesBackgroundAlpha}); + if (highlightSeriesBackgroundColor) utils.update(opts, {highlightSeriesBackgroundColor}); var data = []; for (var j = 0; j < 10; j++) { data.push([j, 0]); } - var graph = document.getElementById("graph"); - return new Dygraph(graph, data, opts); + return new Dygraph('graph', data, opts); } it('testDefaultHighlight', function(done) { @@ -66,7 +66,7 @@ describe("highlight-series-background", function() { }); it('testCustomHighlightColor', function(done) { - var graph = setupGraph(undefined, 'rgb(0,255,255)'); + var graph = setupGraph(null, 'rgb(0,255,255)'); assert.deepEqual(Util.samplePixel(graph.canvas_, 100, 100), [0,0,0,0]); @@ -106,4 +106,4 @@ describe("highlight-series-background", function() { done(); }, 1000); }); -}); \ No newline at end of file +}); diff --git a/src/dygraph.js b/src/dygraph.js index 62c482d..bc75fef 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -1774,7 +1774,7 @@ Dygraph.prototype.updateSelection_ = function(opt_animFraction) { if (this.getOption('highlightSeriesOpts')) { ctx.clearRect(0, 0, this.width_, this.height_); var alpha = 1.0 - this.getNumericOption('highlightSeriesBackgroundAlpha'); - var backgroundColor = Dygraph.toRGB_(this.getOption('highlightSeriesBackgroundColor')); + var backgroundColor = utils.toRGB_(this.getOption('highlightSeriesBackgroundColor')); if (alpha) { // Activating background fade includes an animation effect for a gradual -- 2.7.4