MCPcopy Create free account
hub / github.com/plotly/plotly.js / handleGeoDefaults

Function handleGeoDefaults

src/plots/geo/layout_defaults.js:23–223  ·  view source on GitHub ↗
(geoLayoutIn, geoLayoutOut, coerce, opts)

Source from the content-addressed store, hash-verified

21};
22
23function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
24 var subplotData = getSubplotData(opts.fullData, 'geo', opts.id);
25 var traceIndices = subplotData.map(function(t) { return t.index; });
26
27 var resolution = coerce('resolution');
28 var scope = coerce('scope');
29 var scopeParams = constants.scopeDefaults[scope];
30
31 var projType = coerce('projection.type', scopeParams.projType);
32 var isAlbersUsa = geoLayoutOut._isAlbersUsa = projType === 'albers usa';
33
34 // no other scopes are allowed for 'albers usa' projection
35 if(isAlbersUsa) scope = geoLayoutOut.scope = 'usa';
36
37 var isScoped = geoLayoutOut._isScoped = (scope !== 'world');
38 var isSatellite = geoLayoutOut._isSatellite = projType === 'satellite';
39 var isConic = geoLayoutOut._isConic = projType.indexOf('conic') !== -1 || projType === 'albers';
40 var isClipped = geoLayoutOut._isClipped = !!constants.lonaxisSpan[projType];
41
42 if(geoLayoutIn.visible === false) {
43 // should override template.layout.geo.show* - see issue 4482
44
45 // make a copy
46 var newTemplate = Lib.extendDeep({}, geoLayoutOut._template);
47
48 // override show*
49 newTemplate.showcoastlines = false;
50 newTemplate.showcountries = false;
51 newTemplate.showframe = false;
52 newTemplate.showlakes = false;
53 newTemplate.showland = false;
54 newTemplate.showocean = false;
55 newTemplate.showrivers = false;
56 newTemplate.showsubunits = false;
57 if(newTemplate.lonaxis) newTemplate.lonaxis.showgrid = false;
58 if(newTemplate.lataxis) newTemplate.lataxis.showgrid = false;
59
60 // set ref to copy
61 geoLayoutOut._template = newTemplate;
62 }
63 var visible = coerce('visible');
64
65 var show;
66 for(var i = 0; i < axesNames.length; i++) {
67 var axisName = axesNames[i];
68 var dtickDflt = [30, 10][i];
69 var rangeDflt;
70
71 if(isScoped) {
72 rangeDflt = scopeParams[axisName + 'Range'];
73 } else {
74 var dfltSpans = constants[axisName + 'Span'];
75 var hSpan = (dfltSpans[projType] || dfltSpans['*']) / 2;
76 var rot = coerce(
77 'projection.rotation.' + axisName.slice(0, 3),
78 scopeParams.projRotate[i]
79 );
80 rangeDflt = [rot - hSpan, rot + hSpan];

Callers

nothing calls this directly

Calls 2

unwrapLonRangeFunction · 0.85
coerceFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…