Skip to content

fix for tweaking visible attribute of treemap pathbar #4516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/traces/treemap/plot.js
Original file line number Diff line number Diff line change
@@ -627,5 +627,7 @@ function plotOne(gd, cd, element, transitionOpts) {
hasTransition: hasTransition,
strTransform: strTransform
});
} else {
selAncestors.remove();
}
}
49 changes: 49 additions & 0 deletions test/jasmine/tests/treemap_test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});