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
1 change: 1 addition & 0 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ function drawColorBar(g, opts, gd) {

var fills = g.select('.' + cn.cbfills)
.selectAll('rect.' + cn.cbfill)
.attr('style', '')
.data(fillLevels);
fills.enter().append('rect')
.classed(cn.cbfill, true)
Expand Down
37 changes: 37 additions & 0 deletions test/jasmine/tests/colorbar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,5 +524,42 @@ describe('Test colorbar:', function() {
.catch(failTest)
.then(done);
});

it('creates the same colorbars attributes in newPlot and react', function(done) {
function getCBFillAttributes() {
var attrs = [];
var colorbars = d3.select(gd).selectAll('.colorbar');
colorbars.selectAll('.cbfill').each(function() {
var attrsForElem = {};
for(var i = 0; i < this.attributes.length; i++) {
var attr = this.attributes.item(i);
attrsForElem[attr.name] = attr.value;
}
attrs.push(attrsForElem);
});
return attrs;
}

var z = [[1, 10], [100, 1000]];

var expectedAttrs;
var actualAttrs;

Plotly.newPlot(gd, [{type: 'contour', z: z}])
.then(function() {
expectedAttrs = getCBFillAttributes();

return Plotly.newPlot(gd, [{type: 'heatmap', z: z}])
.then(function() {
return Plotly.react(gd, [{type: 'contour', z: z}]);
});
})
.then(function() {
actualAttrs = getCBFillAttributes();
expect(actualAttrs).toEqual(expectedAttrs);
})
.catch(failTest)
.then(done);
});
});
});