/**
- * @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 = "<div id='graph'></div>";
- });
+describe("highlight-series-background", function() {
- afterEach(function () {
- });
+ cleanupAfterEach();
- function setupGraph(highlightSeriesBackgroundAlpha, highlightSeriesBackgroundColor) {
+ function setupGraph(highlightSeriesBackgroundAlpha,
+ highlightSeriesBackgroundColor) {
var opts = {
width: 480,
height: 320,
}
};
- 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) {
});
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]);
done();
}, 1000);
});
-});
\ No newline at end of file
+});
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