diff --git a/src/plots/cartesian/tick_label_defaults.js b/src/plots/cartesian/tick_label_defaults.js index c899ff91def..446dbd6b7b2 100644 --- a/src/plots/cartesian/tick_label_defaults.js +++ b/src/plots/cartesian/tick_label_defaults.js @@ -25,10 +25,11 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe var showTickLabels = coerce('showticklabels'); if(showTickLabels) { var font = options.font || {}; + var contColor = containerOut.color; // as with titlefont.color, inherit axis.color only if one was // explicitly provided - var dfltFontColor = (containerOut.color !== layoutAttributes.color.dflt) ? - containerOut.color : font.color; + var dfltFontColor = (contColor && contColor !== layoutAttributes.color.dflt) ? + contColor : font.color; Lib.coerceFont(coerce, 'tickfont', { family: font.family, size: font.size, diff --git a/src/traces/box/plot.js b/src/traces/box/plot.js index e8538b22957..236bfe2b7ea 100644 --- a/src/traces/box/plot.js +++ b/src/traces/box/plot.js @@ -90,7 +90,7 @@ function plotBoxAndWhiskers(sel, axes, trace, t) { var paths = sel.selectAll('path.box').data(( trace.type !== 'violin' || - trace.box + trace.box.visible ) ? Lib.identity : []); paths.enter().append('path') @@ -292,7 +292,7 @@ function plotBoxMean(sel, axes, trace, t) { var paths = sel.selectAll('path.mean').data(( (trace.type === 'box' && trace.boxmean) || - (trace.type === 'violin' && trace.box && trace.meanline) + (trace.type === 'violin' && trace.box.visible && trace.meanline.visible) ) ? Lib.identity : []); paths.enter().append('path') diff --git a/src/traces/violin/defaults.js b/src/traces/violin/defaults.js index e0495e83c54..869e7b08320 100644 --- a/src/traces/violin/defaults.js +++ b/src/traces/violin/defaults.js @@ -46,10 +46,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout var boxLineColor = coerce2('box.line.color', lineColor); var boxLineWidth = coerce2('box.line.width', lineWidth); var boxVisible = coerce('box.visible', Boolean(boxWidth || boxFillColor || boxLineColor || boxLineWidth)); - if(!boxVisible) delete traceOut.box; + if(!boxVisible) traceOut.box = {visible: false}; var meanLineColor = coerce2('meanline.color', lineColor); var meanLineWidth = coerce2('meanline.width', lineWidth); var meanLineVisible = coerce('meanline.visible', Boolean(meanLineColor || meanLineWidth)); - if(!meanLineVisible) delete traceOut.meanline; + if(!meanLineVisible) traceOut.meanline = {visible: false}; }; diff --git a/src/traces/violin/plot.js b/src/traces/violin/plot.js index 6912fd6f0f3..43b53a8046e 100644 --- a/src/traces/violin/plot.js +++ b/src/traces/violin/plot.js @@ -138,7 +138,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { d.pathLength = d.path.getTotalLength() / (hasBothSides ? 2 : 1); }); - var boxAttrs = trace.box || {}; + var boxAttrs = trace.box; var boxWidth = boxAttrs.width; var boxLineWidth = (boxAttrs.line || {}).width; var bdPosScaled; @@ -170,7 +170,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { }); var fn; - if(!(trace.box || {}).visible && (trace.meanline || {}).visible) { + if(!trace.box.visible && trace.meanline.visible) { fn = Lib.identity; } diff --git a/test/jasmine/tests/colorbar_test.js b/test/jasmine/tests/colorbar_test.js index 48ab85137d3..6456ea4eb1d 100644 --- a/test/jasmine/tests/colorbar_test.js +++ b/test/jasmine/tests/colorbar_test.js @@ -2,15 +2,46 @@ var d3 = require('d3'); var Plotly = require('@lib/index'); var Colorbar = require('@src/components/colorbar'); + var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); var failTest = require('../assets/fail_test'); +var supplyAllDefaults = require('../assets/supply_defaults'); var assertPlotSize = require('../assets/custom_assertions').assertPlotSize; describe('Test colorbar:', function() { 'use strict'; + describe('supplyDefaults:', function() { + function _supply(trace, layout) { + var gd = { + data: [trace], + layout: layout + }; + supplyAllDefaults(gd); + return gd._fullData[0]; + } + + it('should fill in tickfont defaults', function() { + var out = _supply({ + type: 'heatmap', + z: [[1, 2, 3], [2, 3, 6]] + }); + expect(out.colorbar.tickfont.color).toBe('#444', 'dflt color'); + }); + + it('should inherit tickfont defaults from global font', function() { + var out = _supply({ + type: 'heatmap', + z: [[1, 2, 3], [2, 3, 6]] + }, { + font: {color: 'red'} + }); + expect(out.colorbar.tickfont.color).toBe('red', 'from global font'); + }); + }); + describe('hasColorbar', function() { var hasColorbar = Colorbar.hasColorbar, trace; diff --git a/test/jasmine/tests/gl2d_plot_interact_test.js b/test/jasmine/tests/gl2d_plot_interact_test.js index 827d283c94d..6c456d5f9ee 100644 --- a/test/jasmine/tests/gl2d_plot_interact_test.js +++ b/test/jasmine/tests/gl2d_plot_interact_test.js @@ -27,7 +27,10 @@ describe('@gl Test removal of gl contexts', function() { gd = createGraphDiv(); }); - afterEach(destroyGraphDiv); + afterEach(function() { + Plotly.purge(gd); + destroyGraphDiv(); + }); it('Plots.cleanPlot should remove gl context from the graph div of a gl2d plot', function(done) { Plotly.plot(gd, [{ @@ -41,6 +44,7 @@ describe('@gl Test removal of gl contexts', function() { expect(!!gd._fullLayout._plots.xy._scene).toBe(false); }) + .catch(failTest) .then(done); }); @@ -83,6 +87,7 @@ describe('@gl Test removal of gl contexts', function() { firstCanvas !== secondCanvas && firstGlContext.isContextLost() ); }) + .catch(failTest) .then(done); }); }); @@ -118,6 +123,7 @@ describe('@gl Test gl plot side effects', function() { var rangeSlider = document.getElementsByClassName('range-slider')[0]; expect(rangeSlider).not.toBeDefined(); }) + .catch(failTest) .then(done); }); @@ -160,6 +166,7 @@ describe('@gl Test gl plot side effects', function() { return Plotly.purge(gd); }) + .catch(failTest) .then(done); }); @@ -184,6 +191,7 @@ describe('@gl Test gl plot side effects', function() { .then(function() { expect(d3.selectAll('canvas').size()).toEqual(0); }) + .catch(failTest) .then(done); }); diff --git a/test/jasmine/tests/violin_test.js b/test/jasmine/tests/violin_test.js index c6763ba0c8d..3d5acc95435 100644 --- a/test/jasmine/tests/violin_test.js +++ b/test/jasmine/tests/violin_test.js @@ -124,8 +124,8 @@ describe('Test violin defaults', function() { color: 'red' } }); - expect(traceOut.box).toBeUndefined(); - expect(traceOut.meanline).toBeUndefined(); + expect(traceOut.box).toEqual({visible: false}); + expect(traceOut.meanline).toEqual({visible: false}); }); it('should use violin style settings to default inner style attribute', function() {