Skip to content

Commit

Permalink
fix(voronoi): upgrade d3-delaunay to fix single/collinear points (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc authored Jul 13, 2019
1 parent 2f4ddc4 commit b93c96a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ packages-tslint: ##@1 packages run tslint on all packages
./packages/scatterplot/index.d.ts \
./packages/stream/index.d.ts \
./packages/swarmplot/index.d.ts \
./packages/waffle/index.d.ts
./packages/waffle/index.d.ts \
./packages/voronoi/index.d.ts

package-test-cover-%: ##@1 packages run tests for a package with code coverage
@yarn jest -c ./packages/jest.config.js --rootDir . --coverage ./packages/${*}/tests
Expand Down
2 changes: 1 addition & 1 deletion packages/voronoi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"dependencies": {
"@nivo/core": "0.59.1",
"d3-delaunay": "^4.1.5",
"d3-delaunay": "^5.1.1",
"d3-scale": "^3.0.0",
"recompose": "^0.30.0"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/voronoi/tests/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
env:
jest: true
19 changes: 19 additions & 0 deletions packages/voronoi/tests/computeMesh.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { computeMesh } from '../src/computeMesh'

it(`should be able to compute mesh for collinear points`, () => {
const points = [[0, 0], [50, 50], [100, 100]]

const { voronoi } = computeMesh({ points, width: 500, height: 500, debug: true })

const cells = [...voronoi.cellPolygons()]
expect(cells).toHaveLength(3)
})

it(`should be able to compute mesh for a single point`, () => {
const points = [[50, 50]]

const { voronoi } = computeMesh({ points, width: 500, height: 500, debug: true })

const cells = [...voronoi.cellPolygons()]
expect(cells).toHaveLength(1)
})
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6311,12 +6311,12 @@ d3-color@1, d3-color@^1.2.3:
resolved "https://registry.yarnpkg.com/d3-color/-/d3-color-1.2.3.tgz#6c67bb2af6df3cc8d79efcc4d3a3e83e28c8048f"
integrity sha512-x37qq3ChOTLd26hnps36lexMRhNXEtVxZ4B25rL0DVdDsGQIJGB18S7y9XDwlDD6MD/ZBzITCf4JjGMM10TZkw==

d3-delaunay@^4.1.5:
version "4.1.5"
resolved "https://registry.yarnpkg.com/d3-delaunay/-/d3-delaunay-4.1.5.tgz#4318c6d28b22988d88d11650eda440318afe419a"
integrity sha512-rBKVohmXT9+BrDicH8umAVUwtkfLIydVlWnpIEDUZ4l2e1vXCaKbypByF8tkN8TUUKnzJY0s8ldQEroeBRMO9Q==
d3-delaunay@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/d3-delaunay/-/d3-delaunay-5.1.1.tgz#fa2313f5fff1c6007f7d814276fc6914f370d63c"
integrity sha512-BPT4Ej3tpXe+XdexZnave8XfRZHqRn8CZt2oIO9xBhQAaoKgssa9RHuzeszizpOWqtnh6GHBQmLoE2guhifghA==
dependencies:
delaunator "^2.0.0"
delaunator "4"

d3-dispatch@1:
version "1.0.5"
Expand Down Expand Up @@ -6681,10 +6681,10 @@ del@^3.0.0:
pify "^3.0.0"
rimraf "^2.2.8"

delaunator@^2.0.0:
version "2.0.5"
resolved "https://registry.yarnpkg.com/delaunator/-/delaunator-2.0.5.tgz#c2a9ba2cf3d5aaab8fa0aa3ae82426d3fc0aeaf5"
integrity sha512-GSYmkITO56erpQzv5Pw+8Vg769kurM16IVUq/AcMb5ZCJCtV7Z2agx9lJ7EbbLno8L099iH2d+hvAK34ZnsvIQ==
delaunator@4:
version "4.0.0"
resolved "https://registry.yarnpkg.com/delaunator/-/delaunator-4.0.0.tgz#3630f477b4923f472f534c62a028aeca6fe22d96"
integrity sha512-KzVgOHix5xaIVzZSfbv3Uzw9aI7mQNDet4Yd2p+tBNkfNHMFJbjbVa3q0nC7q7TjWZLX49QbzcT+pXazXX3Qmg==

delayed-stream@~1.0.0:
version "1.0.0"
Expand Down

0 comments on commit b93c96a

Please sign in to comment.