npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

d3-force-bounded-box

0.0.2

@stevemao

npmHomeRepoSnykSocket
Downloads:0
$ npm install d3-force-bounded-box
DailyWeeklyMonthlyYearly

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

Examples:

const boundedBox = require('d3-force-bounded-box')
const { forceSimulation } = require('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);