plotly.js
Version:
The open source javascript graphing library that powers plotly
25 lines (18 loc) • 717 B
JavaScript
var topojsonUtils = module.exports = {};
var locationmodeToLayer = require('../plots/geo/constants').locationmodeToLayer;
var topojsonFeature = require('topojson-client').feature;
topojsonUtils.getTopojsonName = function(geoLayout) {
return [
geoLayout.scope.replace(/ /g, '-'), '_',
geoLayout.resolution.toString(), 'm'
].join('');
};
topojsonUtils.getTopojsonPath = function(topojsonURL, topojsonName) {
return topojsonURL + topojsonName + '.json';
};
topojsonUtils.getTopojsonFeatures = function(trace, topojson) {
var layer = locationmodeToLayer[trace.locationmode];
var obj = topojson.objects[layer];
return topojsonFeature(topojson, obj).features;
};
;