From 39dd6ddf06b26cc4088ba7b3b39a19bd0471a548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 26 Jul 2018 15:10:56 -0400 Subject: [PATCH 1/7] init violin box and meanline containers to {visible:false} ... instead of clearing them entirely, this is more consistent with what the react-chart-editor expects --- src/traces/box/plot.js | 4 ++-- src/traces/violin/defaults.js | 4 ++-- test/jasmine/tests/violin_test.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/traces/box/plot.js b/src/traces/box/plot.js index afc98857029..a8ae0bcf743 100644 --- a/src/traces/box/plot.js +++ b/src/traces/box/plot.js @@ -102,7 +102,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') @@ -304,7 +304,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/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() { From 7d506308d0d3ae206a8212f93f886861a69c9539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 26 Jul 2018 15:58:35 -0400 Subject: [PATCH 2/7] only compare container color to schema color when it exists - this piece here is called by Colorbar.supplyDefaults, but colorbars do not have a container-wide 'color' attribute unlike axes, so the comparison with layoutAttributes.color was off. - this bug did not affect the baselines as this routine is called again during Colorbar.draw with a set container color. --- src/plots/cartesian/tick_label_defaults.js | 5 ++-- test/jasmine/tests/colorbar_test.js | 31 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) 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/test/jasmine/tests/colorbar_test.js b/test/jasmine/tests/colorbar_test.js index a4ff4de3c31..8bb9ba15a06 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; From 37567e924329c9c06e957afe3b54fbb534563373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 27 Jul 2018 10:10:11 -0400 Subject: [PATCH 3/7] simplify box/meanlin visible logic --- src/traces/box/plot.js | 4 ++-- src/traces/violin/plot.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/traces/box/plot.js b/src/traces/box/plot.js index a8ae0bcf743..4c0302bf0b2 100644 --- a/src/traces/box/plot.js +++ b/src/traces/box/plot.js @@ -102,7 +102,7 @@ function plotBoxAndWhiskers(sel, axes, trace, t) { var paths = sel.selectAll('path.box').data(( trace.type !== 'violin' || - (trace.box || {}).visible + trace.box.visible ) ? Lib.identity : []); paths.enter().append('path') @@ -304,7 +304,7 @@ function plotBoxMean(sel, axes, trace, t) { var paths = sel.selectAll('path.mean').data(( (trace.type === 'box' && trace.boxmean) || - (trace.type === 'violin' && (trace.box || {}).visible && (trace.meanline || {}).visible) + (trace.type === 'violin' && trace.box.visible && trace.meanline.visible) ) ? Lib.identity : []); paths.enter().append('path') diff --git a/src/traces/violin/plot.js b/src/traces/violin/plot.js index 6af773346f0..660903a8e59 100644 --- a/src/traces/violin/plot.js +++ b/src/traces/violin/plot.js @@ -147,7 +147,7 @@ module.exports = function plot(gd, plotinfo, cd, 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; @@ -179,7 +179,7 @@ module.exports = function plot(gd, plotinfo, cd, violinLayer) { }); var fn; - if(!(trace.box || {}).visible && (trace.meanline || {}).visible) { + if(!trace.box.visible && trace.meanline.visible) { fn = Lib.identity; } From d657d49bb3b7ef8c466faee8b99d16e1881d73ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 13 Jul 2018 16:03:33 -0400 Subject: [PATCH 4/7] pass dragbox element to mouseEvent ... this reduces the occurance of intermittent failure in the gl2d_click suite on etpinard's laptop --- test/jasmine/tests/gl2d_click_test.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/jasmine/tests/gl2d_click_test.js b/test/jasmine/tests/gl2d_click_test.js index f5fb50e9018..84e9784d4d9 100644 --- a/test/jasmine/tests/gl2d_click_test.js +++ b/test/jasmine/tests/gl2d_click_test.js @@ -593,17 +593,19 @@ describe('@noCI @gl Test gl2d lasso/select:', function() { function drag(path) { var len = path.length; + var el = d3.select(gd).select('rect.nsewdrag').node(); + var opts = {element: el}; Lib.clearThrottle(); - mouseEvent('mousemove', path[0][0], path[0][1]); - mouseEvent('mousedown', path[0][0], path[0][1]); + mouseEvent('mousemove', path[0][0], path[0][1], opts); + mouseEvent('mousedown', path[0][0], path[0][1], opts); path.slice(1, len).forEach(function(pt) { Lib.clearThrottle(); - mouseEvent('mousemove', pt[0], pt[1]); + mouseEvent('mousemove', pt[0], pt[1], opts); }); - mouseEvent('mouseup', path[len - 1][0], path[len - 1][1]); + mouseEvent('mouseup', path[len - 1][0], path[len - 1][1], opts); } function select(path) { From dd2e07391cdbc8cc94c9db4ac5cf7d3444d5dcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Tue, 31 Jul 2018 17:31:12 -0400 Subject: [PATCH 5/7] purge better in-between gl2d tests --- test/jasmine/tests/gl2d_plot_interact_test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/jasmine/tests/gl2d_plot_interact_test.js b/test/jasmine/tests/gl2d_plot_interact_test.js index 94516d5b7b7..4d7c1119df6 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); }); From f43cada3eb5caac309a1a14fed1ff1210cf09e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 1 Aug 2018 10:24:55 -0400 Subject: [PATCH 6/7] skip remove gl context test on CI --- test/jasmine/tests/gl2d_plot_interact_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/gl2d_plot_interact_test.js b/test/jasmine/tests/gl2d_plot_interact_test.js index 4d7c1119df6..c6d8e7920fd 100644 --- a/test/jasmine/tests/gl2d_plot_interact_test.js +++ b/test/jasmine/tests/gl2d_plot_interact_test.js @@ -48,7 +48,7 @@ describe('@gl Test removal of gl contexts', function() { .then(done); }); - it('Plotly.newPlot should remove gl context from the graph div of a gl2d plot', function(done) { + it('@noCI Plotly.newPlot should remove gl context from the graph div of a gl2d plot', function(done) { var firstGlplotObject, firstGlContext, firstCanvas; Plotly.plot(gd, [{ From 2ed8a6a0cb70505dcc58d03475fb44586ad2b8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 17 Aug 2018 15:33:53 -0400 Subject: [PATCH 7/7] Revert "skip remove gl context test on CI" This reverts commit f43cada3eb5caac309a1a14fed1ff1210cf09e04. --- test/jasmine/tests/gl2d_plot_interact_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/gl2d_plot_interact_test.js b/test/jasmine/tests/gl2d_plot_interact_test.js index 4fb329f42f1..6c456d5f9ee 100644 --- a/test/jasmine/tests/gl2d_plot_interact_test.js +++ b/test/jasmine/tests/gl2d_plot_interact_test.js @@ -48,7 +48,7 @@ describe('@gl Test removal of gl contexts', function() { .then(done); }); - it('@noCI Plotly.newPlot should remove gl context from the graph div of a gl2d plot', function(done) { + it('Plotly.newPlot should remove gl context from the graph div of a gl2d plot', function(done) { var firstGlplotObject, firstGlContext, firstCanvas; Plotly.plot(gd, [{