Skip to content

Commit e06b6c0

Browse files
adjust shamefullyAdjustGeo
1 parent 4782500 commit e06b6c0

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/shame.js

+22-13
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,28 @@ export const shamefullyAdjustAxisRef = (graphDiv, payload) => {
7171
}
7272
};
7373

74-
export const shamefullyAdjustGeo = ({layout: {geo = {}}}, {update}) => {
75-
if (update['geo.scope']) {
76-
update['geo.projection'] = {};
77-
update['geo.center'] = {};
78-
}
79-
if (
80-
// requesting projection change
81-
update['geo.projection.type'] &&
82-
(update['geo.projection.type'] === 'albers usa' || geo.scope === 'usa')
83-
) {
84-
update['geo.scope'] = {};
85-
update['geo.center'] = {};
86-
}
74+
const geoRegex = /^(geo\d*)\./;
75+
export const shamefullyAdjustGeo = ({layout}, {update}) => {
76+
Object.keys(update).forEach(k => {
77+
const geoMatch = geoRegex.exec(k);
78+
if (geoMatch) {
79+
const geo = geoMatch[1];
80+
if (update[geo + '.scope']) {
81+
update[geo + '.projection'] = {};
82+
update[geo + '.center'] = {};
83+
}
84+
85+
if (
86+
// requesting projection change
87+
update[geo + '.projection.type'] &&
88+
(update[geo + '.projection.type'] === 'albers usa' ||
89+
(layout[geo] && layout[geo].scope === 'usa'))
90+
) {
91+
update[geo + '.scope'] = {};
92+
update[geo + '.center'] = {};
93+
}
94+
}
95+
});
8796
};
8897

8998
export const shamefullyAddTableColumns = (graphDiv, {traceIndexes, update}) => {

0 commit comments

Comments
 (0)