Skip to content

Commit 7296fb7

Browse files
committed
fix 4971 - empty axis categories only on react call not relayout
1 parent 1e431a1 commit 7296fb7

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/lib/relink_private.js

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) {
2525
var toVal = toContainer[k];
2626

2727
if(toVal === fromVal) continue;
28-
if(toContainer.matches && k === '_categoriesMap') continue;
2928

3029
if(k.charAt(0) === '_' || typeof fromVal === 'function') {
3130
// if it already exists at this point, it's something

src/plot_api/plot_api.js

+10
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,16 @@ function react(gd, data, layout, config) {
27122712

27132713
applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout);
27142714

2715+
var allNames = Object.getOwnPropertyNames(oldFullLayout);
2716+
for(var q = 0; q < allNames.length; q++) {
2717+
var name = allNames[q];
2718+
var start = name.substring(0, 5);
2719+
if(start === 'xaxis' || start === 'yaxis') {
2720+
var emptyCategories = oldFullLayout[name]._emptyCategories;
2721+
if(emptyCategories) emptyCategories();
2722+
}
2723+
}
2724+
27152725
// "true" skips updating calcdata and remapping arrays from calcTransforms,
27162726
// which supplyDefaults usually does at the end, but we may need to NOT do
27172727
// if the diff (which we haven't determined yet) says we'll recalc

test/jasmine/tests/axes_test.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -5580,7 +5580,7 @@ describe('more react tests', function() {
55805580

55815581
afterEach(destroyGraphDiv);
55825582

5583-
it('should sort catgories on matching axes using react', function(done) {
5583+
it('should sort catgories on matching axes using react and relink using relayout', function(done) {
55845584
var fig = {
55855585
data: [{
55865586
yaxis: 'y',
@@ -5696,6 +5696,16 @@ describe('more react tests', function() {
56965696
expect(gd._fullLayout.xaxis._categoriesMap).toEqual({Z: 0, 0: 1, A: 2});
56975697
expect(gd._fullLayout.xaxis2._categoriesMap).toEqual({Z: 0, 0: 1, A: 2});
56985698
})
5699+
.then(function() {
5700+
// should get the same order with relayout
5701+
return Plotly.relayout(gd, 'width', 600);
5702+
})
5703+
.then(function() {
5704+
expect(gd._fullLayout.xaxis._categories).toEqual(['Z', '0', 'A']);
5705+
expect(gd._fullLayout.xaxis2._categories).toEqual(['Z', '0', 'A']);
5706+
expect(gd._fullLayout.xaxis._categoriesMap).toEqual({Z: 0, 0: 1, A: 2});
5707+
expect(gd._fullLayout.xaxis2._categoriesMap).toEqual({Z: 0, 0: 1, A: 2});
5708+
})
56995709
.catch(failTest)
57005710
.then(done);
57015711
});

0 commit comments

Comments
 (0)