Skip to content

Commit 8122c21

Browse files
authoredJan 27, 2020
Merge pull request #4516 from plotly/react-pathbar-visible
fix for tweaking visible attribute of treemap pathbar
2 parents 1f1b9b6 + 838d1c3 commit 8122c21

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
 

Diff for: ‎src/traces/treemap/plot.js

+2
Original file line numberDiff line numberDiff line change
@@ -627,5 +627,7 @@ function plotOne(gd, cd, element, transitionOpts) {
627627
hasTransition: hasTransition,
628628
strTransform: strTransform
629629
});
630+
} else {
631+
selAncestors.remove();
630632
}
631633
}

Diff for: ‎test/jasmine/tests/treemap_test.js

+49
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var assertHoverLabelStyle = customAssertions.assertHoverLabelStyle;
1717
var assertHoverLabelContent = customAssertions.assertHoverLabelContent;
1818
var checkTextTemplate = require('../assets/check_texttemplate');
1919

20+
var SLICES_SELECTOR = '.treemaplayer path.surface';
2021
var SLICES_TEXT_SELECTOR = '.treemaplayer text.slicetext';
2122

2223
function _mouseEvent(type, gd, v) {
@@ -1889,3 +1890,51 @@ describe('treemap uniformtext', function() {
18891890
.then(done);
18901891
});
18911892
});
1893+
1894+
describe('treemap pathbar react', function() {
1895+
'use strict';
1896+
1897+
var gd;
1898+
1899+
beforeEach(function() {
1900+
gd = createGraphDiv();
1901+
});
1902+
1903+
afterEach(destroyGraphDiv);
1904+
1905+
it('should show and hide pathbar', function(done) {
1906+
var fig = {
1907+
data: [{
1908+
type: 'treemap',
1909+
parents: ['', 'A', 'B', 'C'],
1910+
labels: ['A', 'B', 'C', 'D'],
1911+
level: 'C'
1912+
}],
1913+
layout: {}
1914+
};
1915+
1916+
function _assert(msg, exp) {
1917+
return function() {
1918+
var selection = d3.selectAll(SLICES_SELECTOR);
1919+
var size = selection.size();
1920+
1921+
expect(size).toBe(exp, msg);
1922+
};
1923+
}
1924+
1925+
Plotly.plot(gd, fig)
1926+
.then(_assert('default pathbar.visible: true', 4))
1927+
.then(function() {
1928+
fig.data[0].pathbar = {visible: false};
1929+
return Plotly.react(gd, fig);
1930+
})
1931+
.then(_assert('disable pathbar', 2))
1932+
.then(function() {
1933+
fig.data[0].pathbar = {visible: true};
1934+
return Plotly.react(gd, fig);
1935+
})
1936+
.then(_assert('enable pathbar', 4))
1937+
.catch(failTest)
1938+
.then(done);
1939+
});
1940+
});

0 commit comments

Comments
 (0)