Developing on `d3-geo-projection` for d3 v4
This visualization gallery example documents the process of upgrading the `d3-geo-projection` library to work with d3 v4. It shows a workflow of checking out the `4` branch, restoring broken projection source files from a `4-broken` tag, and iteratively testing and tweaking projections like Robinson using `npm test` and `test/compute-scale`. The example also demonstrates publishing test outputs to a gist via `gistup` and preparing pull requests by comparing branches on GitHub.
AI-generated descriptionDeveloping on d3-geo-projection for d3 v4
download code
git clone https://github.com/d3/d3-geo-projection
cd d3-geo-projection/
git checkout --track origin/4
download dependencies
npm install
(at first I thought I had to npm install d3-geo canvas package-preamble rollup tape eslint, my mistake)
Make sure you have a recent version of compare (mine was an old thing in MAMP, just delete it or remove it from $PATH)
brew install optipng
run tests
npm test 2>&1 | tee test/output/testlog.txt
publish tests
first time:
cd test/output/ && gistup
afterwards:
cd test/output/ && git commit -a -m"up" && git push
Editing a projection from 4-broken
projection=robinson
branch=geoRobinson
projection=...
branch=geo...
git checkout 4
git checkout -b $branch
git cat-file blob 4-broken:src/$projection.js > src/$projection.js
bbedit test/compare-images README.md src/$projection.js index.js
test/compute-scale $projection
npm run pretest && test/render-world $projection
tweak until tests work
optipng test/output/$projection.png
cp test/output/$projection.png img/
bbedit test/compare-images
git add test/compare-images index.js README.md src/$projection.js img/$projection.png
git diff
git status
Inspect.
Create the PR
git commit -a -m"$projection v4"
git push --set-upstream origin $branch
open https://github.com/d3/d3-geo-projection/compare/4...Fil:$branch?expand=1