Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Fit methods #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"main": "dist/geo-albers-usa-territories.js",
"scripts": {
"prepublish": "rollup --config",
"postpublish": "git push && git push --tags"
"postpublish": "git push && git push --tags",
"prettier": "prettier './src/**/*.js' 'rollup.config.js' --write"
},
"prettier": {
"singleQuote": true
},
"repository": {
"type": "git",
Expand All @@ -31,8 +35,11 @@
},
"homepage": "https://github.com/stamen/geo-albers-usa-territories#readme",
"devDependencies": {
"@rollup/plugin-node-resolve": "^9.0.0",
"d3-geo": "^2.0.1",
"prettier": "^2.1.1",
"rollup": "^2.26.11",
"d3-geo": "^2.0.1"
"rollup-plugin-commonjs": "^10.1.0"
},
"peerDependencies": {
"d3-geo": "^2.0.1"
Expand Down
16 changes: 11 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
input: 'src/index.js',
external: ['d3-geo'],
output: {
file: 'dist/geo-albers-usa-territories.js',
format: 'umd',
name: 'geoAlbersUsaTerritories',
globals: {
'd3-geo': 'd3'
}
}
},
// external: ['d3-geo', 'd3-geo/src/fit.js'],
plugins: [
nodeResolve(),
commonjs({
include: 'node_modules/**',
}),
],
};
17 changes: 17 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { geoAlbers, geoConicEqualArea } from 'd3-geo';
import { fitExtent, fitSize, fitWidth, fitHeight } from 'd3-geo/src/fit.js';

var epsilon = 0.000001;

Expand Down Expand Up @@ -186,6 +187,22 @@ export function geoAlbersUsaTerritories() {
return reset();
};

albersUsaTerritories.fitExtent = function (extent, object) {
return fitExtent(albersUsaTerritories, extent, object);
};

albersUsaTerritories.fitSize = function (size, object) {
return fitSize(albersUsaTerritories, size, object);
};

albersUsaTerritories.fitWidth = function (width, object) {
return fitWidth(albersUsaTerritories, width, object);
};

albersUsaTerritories.fitHeight = function (height, object) {
return fitHeight(albersUsaTerritories, height, object);
};

function reset() {
cache = cacheStream = null;
return albersUsaTerritories;
Expand Down