Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 504 Bytes

readme.md

File metadata and controls

25 lines (20 loc) · 504 Bytes

A D3 force. Inspired by https://bl.ocks.org/cmgiven/547658968d365bcc324f3e62e175709b

Examples:

import boundedBox from 'd3-force-bounded-box'
import { forceSimulation } from 'd3-force'

const nodeData = [
  {
    size: 52,
    x: 0,
    y: 0,
    vx: 0,
    vy: 0,
  }
]

const boxForce = boundedBox()
  .bounds([[0, 0], [width, height]])
  .size(d => [d.size, d.size]);

const simulation = forceSimulation(nodeData)
  .force('boxForce', boxForce);