Skip to content
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

Fixup bartext removal in update selections #2689

Merged
merged 1 commit into from Jun 4, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

rm bartext element (if any) in update selection

... when tx item is blank or textposition is 'none'
  • Loading branch information...
etpinard committed Jun 1, 2018
commit 96a7b12ba1bb37999ead963e4be96deb43d7481c
@@ -189,10 +189,12 @@ function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) {
orientation = trace.orientation;

var text = getText(trace, i);
if(!text) return;

textPosition = getTextPosition(trace, i);
if(textPosition === 'none') return;

if(!text || textPosition === 'none') {
bar.select('text').remove();
return;
}

var textFont = getTextFont(trace, i, gd._fullLayout.font),
insideTextFont = getInsideTextFont(trace, i, textFont),
@@ -1294,6 +1294,43 @@ describe('A bar plot', function() {
.catch(fail)
.then(done);
});

it('should be able to add/remove text node on restyle', function(done) {
function _assertNumberOfBarTextNodes(cnt) {
var sel = d3.select(gd).select('.barlayer').selectAll('text');
expect(sel.size()).toBe(cnt);
}

Plotly.plot(gd, [{
type: 'bar',
x: ['Product A', 'Product B', 'Product C'],
y: [20, 14, 23],
text: [20, 14, 23],
textposition: 'auto'
}])
.then(function() {
_assertNumberOfBarTextNodes(3);
return Plotly.restyle(gd, 'textposition', 'none');
})
.then(function() {
_assertNumberOfBarTextNodes(0);
return Plotly.restyle(gd, 'textposition', 'auto');
})
.then(function() {
_assertNumberOfBarTextNodes(3);
return Plotly.restyle(gd, 'text', [[null, 0, '']]);
})
.then(function() {
// N.B. that '0' should be there!
_assertNumberOfBarTextNodes(1);
return Plotly.restyle(gd, 'text', 'yo!');
})
.then(function() {
_assertNumberOfBarTextNodes(3);
})
.catch(fail)
.then(done);
});
});

describe('bar hover', function() {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.