Skip to content

Commit 326cb04

Browse files
committed
remove invisible pathbar
- add test to show/hide pathbar using react
1 parent 1f1b9b6 commit 326cb04

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ function plotOne(gd, cd, element, transitionOpts) {
103103
return;
104104
}
105105

106+
if(!trace.pathbar.visible) {
107+
selAncestors.remove();
108+
}
109+
106110
var isRoot = helpers.isHierarchyRoot(entry);
107111
var hasTransition = !fullLayout.uniformtext.mode && helpers.hasTransition(transitionOpts);
108112

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)