diff --git a/src/traces/treemap/plot.js b/src/traces/treemap/plot.js index 4f2deb49b33..a60e1495fdd 100644 --- a/src/traces/treemap/plot.js +++ b/src/traces/treemap/plot.js @@ -627,5 +627,7 @@ function plotOne(gd, cd, element, transitionOpts) { hasTransition: hasTransition, strTransform: strTransform }); + } else { + selAncestors.remove(); } } diff --git a/test/jasmine/tests/treemap_test.js b/test/jasmine/tests/treemap_test.js index 45297d53d85..f5788260b2d 100644 --- a/test/jasmine/tests/treemap_test.js +++ b/test/jasmine/tests/treemap_test.js @@ -17,6 +17,7 @@ var assertHoverLabelStyle = customAssertions.assertHoverLabelStyle; var assertHoverLabelContent = customAssertions.assertHoverLabelContent; var checkTextTemplate = require('../assets/check_texttemplate'); +var SLICES_SELECTOR = '.treemaplayer path.surface'; var SLICES_TEXT_SELECTOR = '.treemaplayer text.slicetext'; function _mouseEvent(type, gd, v) { @@ -1889,3 +1890,51 @@ describe('treemap uniformtext', function() { .then(done); }); }); + +describe('treemap pathbar react', function() { + 'use strict'; + + var gd; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(destroyGraphDiv); + + it('should show and hide pathbar', function(done) { + var fig = { + data: [{ + type: 'treemap', + parents: ['', 'A', 'B', 'C'], + labels: ['A', 'B', 'C', 'D'], + level: 'C' + }], + layout: {} + }; + + function _assert(msg, exp) { + return function() { + var selection = d3.selectAll(SLICES_SELECTOR); + var size = selection.size(); + + expect(size).toBe(exp, msg); + }; + } + + Plotly.plot(gd, fig) + .then(_assert('default pathbar.visible: true', 4)) + .then(function() { + fig.data[0].pathbar = {visible: false}; + return Plotly.react(gd, fig); + }) + .then(_assert('disable pathbar', 2)) + .then(function() { + fig.data[0].pathbar = {visible: true}; + return Plotly.react(gd, fig); + }) + .then(_assert('enable pathbar', 4)) + .catch(failTest) + .then(done); + }); +});