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

Function calcGeoJSON

src/traces/choropleth/plot.js:31–73  ·  view source on GitHub ↗
(calcTrace, fullLayout)

Source from the content-addressed store, hash-verified

29}
30
31function calcGeoJSON(calcTrace, fullLayout) {
32 var trace = calcTrace[0].trace;
33 var geoLayout = fullLayout[trace.geo];
34 var geo = geoLayout._subplot;
35 var locationmode = trace.locationmode;
36 var len = trace._length;
37
38 var features = locationmode === 'geojson-id' ?
39 geoUtils.extractTraceFeature(calcTrace) :
40 getTopojsonFeatures(trace, geo.topojson);
41
42 var lonArray = [];
43 var latArray = [];
44
45 for(var i = 0; i < len; i++) {
46 var calcPt = calcTrace[i];
47 var feature = locationmode === 'geojson-id' ?
48 calcPt.fOut :
49 geoUtils.locationToFeature(locationmode, calcPt.loc, features);
50
51 if(feature) {
52 calcPt.geojson = feature;
53 calcPt.ct = feature.properties.ct;
54 calcPt._polygons = geoUtils.feature2polygons(feature);
55
56 var bboxFeature = geoUtils.computeBbox(feature);
57 lonArray.push(bboxFeature[0], bboxFeature[2]);
58 latArray.push(bboxFeature[1], bboxFeature[3]);
59 } else {
60 calcPt.geojson = null;
61 }
62 }
63
64 if(geoLayout.fitbounds === 'geojson' && locationmode === 'geojson-id') {
65 var bboxGeojson = geoUtils.computeBbox(geoUtils.getTraceGeojson(trace));
66 lonArray = [bboxGeojson[0], bboxGeojson[2]];
67 latArray = [bboxGeojson[1], bboxGeojson[3]];
68 }
69
70 var opts = {padded: true};
71 trace._extremes.lon = findExtremes(geoLayout.lonaxis._ax, lonArray, opts);
72 trace._extremes.lat = findExtremes(geoLayout.lataxis._ax, latArray, opts);
73}
74
75module.exports = {
76 calcGeoJSON: calcGeoJSON,

Callers

nothing calls this directly

Calls 1

findExtremesFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…