Skip to content
Merged
Show file tree
Hide file tree
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/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ module.exports = function draw(gd, opts) {
.text(title.text);

textLayout(titleEl, scrollBox, gd, opts); // handle mathjax or multi-line text and compute title height
} else {
scrollBox.selectAll('.legendtitletext').remove();
}

var scrollBar = Lib.ensureSingle(legend, 'rect', 'scrollbar', function(s) {
Expand Down
36 changes: 36 additions & 0 deletions test/jasmine/tests/legend_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,42 @@ describe('legend relayout update', function() {
.catch(failTest)
.then(done);
});

it('should be able to clear legend title using react', function(done) {
var data = [{
type: 'scatter',
x: [0, 1],
y: [1, 0]
}];

Plotly.newPlot(gd, {
data: data,
layout: {
showlegend: true,
legend: {
title: {
text: 'legend<br>title'
}
}
}
})
.then(function() {
expect(d3.selectAll('.legendtitletext')[0].length).toBe(1);
})
.then(function() {
Plotly.react(gd, {
data: data,
layout: {
showlegend: true
}
});
})
.then(function() {
expect(d3.selectAll('.legendtitletext')[0].length).toBe(0);
})
.catch(failTest)
.then(done);
});
});

describe('legend orientation change:', function() {
Expand Down