Skip to content

Commit 2907f59

Browse files
committed
fix: correct colorbar editType for map traces (issue #5616)
scattermap, scattergeo, and scattermapbox had all colorbar properties with editType='calc' instead of 'colorbars', causing the entire plot to recalculate when colorbar properties changed during initialization. This broke map rendering for scattermap/scattergeo/scattermapbox when marker.colorbar properties (e.g. tickfont.textcase) were set on initial render. Changes: - Added restoreColorbarEditTypes() function to each map trace type - Restores colorbar properties to editType='colorbars' after overrideAll - Regenerated test/plot-schema.json with corrected editTypes Fixes #5616 Closes #5616
1 parent a29fbae commit 2907f59

4 files changed

Lines changed: 324 additions & 228 deletions

File tree

src/traces/scattergeo/attributes.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,39 @@ const breakingChangeWarning = [
1919
'Country names in existing plots may not work in the new version.'
2020
].join(' ');
2121

22-
module.exports = overrideAll(
22+
function restoreColorbarEditTypes(attrs) {
23+
function restoreEditTypes(obj) {
24+
for(var key in obj) {
25+
var val = obj[key];
26+
if(val && typeof val === 'object') {
27+
if(val.editType === 'calc') {
28+
val.editType = 'colorbars';
29+
}
30+
if(!val.valType) {
31+
restoreEditTypes(val);
32+
}
33+
if(Array.isArray(val.items)) {
34+
for(var i = 0; i < val.items.length; i++) {
35+
if(val.items[i] && typeof val.items[i] === 'object') {
36+
if(val.items[i].editType === 'calc') {
37+
val.items[i].editType = 'colorbars';
38+
}
39+
if(!val.items[i].valType) {
40+
restoreEditTypes(val.items[i]);
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
48+
if(attrs && attrs.marker && attrs.marker.colorbar) {
49+
restoreEditTypes(attrs.marker.colorbar);
50+
}
51+
return attrs;
52+
}
53+
54+
module.exports = restoreColorbarEditTypes(overrideAll(
2355
{
2456
lon: {
2557
valType: 'data_array',
@@ -175,4 +207,4 @@ module.exports = overrideAll(
175207
},
176208
'calc',
177209
'nested'
178-
);
210+
));

src/traces/scattermap/attributes.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,39 @@ var mapLayoutAtributes = require('../../plots/map/layout_attributes');
1515
var lineAttrs = scatterGeoAttrs.line;
1616
var markerAttrs = scatterGeoAttrs.marker;
1717

18-
module.exports = overrideAll(
18+
function restoreColorbarEditTypes(attrs) {
19+
function restoreEditTypes(obj) {
20+
for(var key in obj) {
21+
var val = obj[key];
22+
if(val && typeof val === 'object') {
23+
if(val.editType === 'calc') {
24+
val.editType = 'colorbars';
25+
}
26+
if(!val.valType) {
27+
restoreEditTypes(val);
28+
}
29+
if(Array.isArray(val.items)) {
30+
for(var i = 0; i < val.items.length; i++) {
31+
if(val.items[i] && typeof val.items[i] === 'object') {
32+
if(val.items[i].editType === 'calc') {
33+
val.items[i].editType = 'colorbars';
34+
}
35+
if(!val.items[i].valType) {
36+
restoreEditTypes(val.items[i]);
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
if(attrs && attrs.marker && attrs.marker.colorbar) {
45+
restoreEditTypes(attrs.marker.colorbar);
46+
}
47+
return attrs;
48+
}
49+
50+
module.exports = restoreColorbarEditTypes(overrideAll(
1951
{
2052
lon: scatterGeoAttrs.lon,
2153
lat: scatterGeoAttrs.lat,
@@ -177,4 +209,4 @@ module.exports = overrideAll(
177209
},
178210
'calc',
179211
'nested'
180-
);
212+
));

src/traces/scattermapbox/attributes.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,39 @@ var mapboxLayoutAtributes = require('../../plots/mapbox/layout_attributes');
1515
var lineAttrs = scatterGeoAttrs.line;
1616
var markerAttrs = scatterGeoAttrs.marker;
1717

18-
module.exports = overrideAll(
18+
function restoreColorbarEditTypes(attrs) {
19+
function restoreEditTypes(obj) {
20+
for(var key in obj) {
21+
var val = obj[key];
22+
if(val && typeof val === 'object') {
23+
if(val.editType === 'calc') {
24+
val.editType = 'colorbars';
25+
}
26+
if(!val.valType) {
27+
restoreEditTypes(val);
28+
}
29+
if(Array.isArray(val.items)) {
30+
for(var i = 0; i < val.items.length; i++) {
31+
if(val.items[i] && typeof val.items[i] === 'object') {
32+
if(val.items[i].editType === 'calc') {
33+
val.items[i].editType = 'colorbars';
34+
}
35+
if(!val.items[i].valType) {
36+
restoreEditTypes(val.items[i]);
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
if(attrs && attrs.marker && attrs.marker.colorbar) {
45+
restoreEditTypes(attrs.marker.colorbar);
46+
}
47+
return attrs;
48+
}
49+
50+
module.exports = restoreColorbarEditTypes(overrideAll(
1951
{
2052
lon: scatterGeoAttrs.lon,
2153
lat: scatterGeoAttrs.lat,
@@ -177,4 +209,4 @@ module.exports = overrideAll(
177209
},
178210
'calc',
179211
'nested'
180-
);
212+
));

0 commit comments

Comments
 (0)