Skip to content

Commit e3b0ca3

Browse files
committed
produce geo_fitbounds-locations using a script
1 parent 17c9f0c commit e3b0ca3

File tree

2 files changed

+82
-5
lines changed

2 files changed

+82
-5
lines changed

src/plots/geo/constants.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,85 @@ exports.projNames = {
126126
*/
127127
};
128128

129+
var keys = Object.keys(exports.projNames);
130+
var totalN = keys.length;
131+
var nRow = 8;
132+
var nCol = Math.ceil(totalN / nRow);
133+
var layout = {
134+
grid: {
135+
rows: nRow,
136+
columns: nCol
137+
},
138+
showlegend: false,
139+
width: 650,
140+
height: 1200,
141+
margin: {
142+
l: 20,
143+
t: 20,
144+
r: 20,
145+
b: 20
146+
},
147+
annotations: [{
148+
showarrow: false,
149+
text: 'fitbounds<br>\'locations\'<br>for all<br>projection<br>types',
150+
font: { size: 24 },
151+
x: 1,
152+
xref: 'paper',
153+
xanchor: 'right',
154+
y: 0.1,
155+
yanchor: 'bottom'
156+
}],
157+
};
158+
var data = [];
159+
var n = -1;
160+
for(var col = 0; col < nCol; col++) {
161+
for(var row = 0; row < nRow; row++) {
162+
n++;
163+
if(n >= totalN) continue;
164+
165+
var name = keys[n];
166+
var geo = 'geo' + (n ? n + 1 : '');
167+
var usa = name.indexOf('usa') !== -1;
168+
var locationmode = usa ? 'USA-states' : undefined;
169+
var locations = [usa ? 'WA' : 'AUS'];
170+
171+
data.push({
172+
name: name,
173+
geo: geo,
174+
type: 'choropleth',
175+
locationmode: locationmode,
176+
locations: locations,
177+
z: [10],
178+
showscale: false,
179+
hovertemplate: name
180+
});
181+
182+
data.push({
183+
geo: geo,
184+
type: 'scattergeo',
185+
mode: 'text',
186+
text: name.replace(' ', '<br>'),
187+
locationmode: locationmode,
188+
locations: locations,
189+
hoverinfo: 'skip'
190+
});
191+
192+
layout[geo] = {
193+
domain: {
194+
row: row,
195+
column: col,
196+
},
197+
projection: { type: name },
198+
fitbounds: 'locations'
199+
};
200+
}
201+
}
202+
203+
console.log(JSON.stringify({
204+
data: data,
205+
layout: layout
206+
}, null, 2));
207+
129208
// name of the axes
130209
exports.axesNames = ['lonaxis', 'lataxis'];
131210

test/image/mocks/geo_fitbounds-locations.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,14 @@
429429
"hovertemplate": "albers usa"
430430
},
431431
{
432-
"name": "albers usa",
433432
"geo": "geo19",
434433
"type": "scattergeo",
434+
"mode": "text",
435+
"text": "albers<br>usa",
435436
"locationmode": "USA-states",
436437
"locations": [
437438
"WA"
438439
],
439-
"mode": "text",
440-
"text": "albers<br>usa",
441440
"hoverinfo": "skip"
442441
},
443442
{
@@ -726,8 +725,7 @@
726725
"projection": {
727726
"type": "albers usa"
728727
},
729-
"fitbounds": "locations",
730-
"scope": "usa"
728+
"fitbounds": "locations"
731729
},
732730
"geo20": {
733731
"domain": {

0 commit comments

Comments
 (0)