npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-force-boundary

v0.0.3

Published

A d3 force for making nodes stay inside a boundary

Downloads

5,989

Readme

d3-force-boundary

# forceBoundary(x0, y0, x1, x1) <>

Creates a new positioning force that tries to keep elements inside a defined boundary defined by x0,y0 and x1,y1. This is useful when you want to guarantee that all nodes remain visible inside the visualization.

# boundary.strength([strength]) <>

If strength is specified, sets the strength accessor to the specified number or function, re-evaluates the strength accessor for each node, and returns this force. The strength determines how much to increment the node’s x- and y-velocity. For example, a value of 0.1 indicates that the node should move a tenth of the way from its current position to the closest point on the circle with each application. Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints. A value outside the range [0,1] is not recommended.

If strength is not specified, returns the current strength accessor, which defaults to:

function strength() {
  return 0.1;
}

The strength accessor is invoked for each node in the simulation, being passed the node and its zero-based index. The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or when this method is called with a new strength, and not on every application of the force.

# boundary.x0([x0]) <>

If x0 is specified, sets the starting x-coordinate of the boundary as an accessor (can be a function). If x0 is not specified, returns the current starting x-coordinate of the boundary.

# boundary.y0([y0]) <>

If y0 is specified, sets the starting y-coordinate of the boundary as an accessor (can be a function). If y0 is not specified, returns the current starting y-coordinate of the boundary.

# boundary.x1([x1]) <>

If x1 is specified, sets the ending x-coordinate of the boundary as an accessor (can be a function). If x is not specified, returns the current ending x-coordinate of the boundary.

# boundary.y1([y1]) <>

If y1 is specified, sets the ending y-coordinate of the boundary as an accessor (can be a function). If y1 is not specified, returns the current ending y-coordinate of the boundary.

# boundary.border([border]) <>

If border is specified, the force would work only at a border distance from the boundary. If border is not specified, returns the current border that defaults to the middle point of the border. Setting a border is useful when you only want to apply the force on the nodes that are reaching the boundary.

Boundary Forces with a border of 100 pixels

Boundary Forces with default border

# boundary.hardBoundary([hardBoundary]) <>

If hardBoundary is specified and is a falsifiable value it will determine if the nodes are going to be forced to be inside the boundary. A false value will try to send the nodes inside the boundary, but won't force them. If hardBoundary is not specified, returns the current hardBoundary that defaults to true.

Installing

For the web

<script src="https://unpkg.com/[email protected]/dist/d3-force-boundary.min.js"></script>

With modules

npm install d3-force-boundary

Observable demo