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

deep-partition-layout

v1.0.0

Published

A fork of d3's partition layout which includes the values of inner nodes in its final sums

Downloads

40

Readme

deep-partition-layout

A fork of d3's partition layout which includes the values of inner nodes in its final sums.

Usage

partition = Partition()

Creates a new partition layout instance.

partition.children([children])

If children is specified, sets the specified children accessor function. If children is not specified, returns the current children accessor function, which by default assumes that the input data is an object with a children array:

function children(d) {
  return d.children
}

partition.value([value])

If value is specified, sets the value accessor to the specified function. If value is not specified, returns the current value accessor, which assumes that the input data is an object with a numeric value attribute:

function value(d) {
  return d.value
}

Note: multiple calls to partition.nodes on the same root node will result in re-accummulating each node's values. It's wise to have your value accessor set to something other than the default to avoid unexpected results.

partition.sort([comparator])

If comparator is specified, sets the sort order of sibling nodes for the layout using the specified comparator function. If comparator is not specified, returns the current group sort order, which defaults to descending order by the associated input data's numeric value attribute:

function comparator(a, b) {
  return b.value - a.value
}

partition.size([size])

If size is specified, sets the available layout size to the specified two-element array of numbers representing x and y.

import Partition from 'deep-partition-layout'

const width = 320
const height = 240
const partition = Partition()
  .size([width, height])

partition.nodes(root)

Runs the partition layout, returning the array of nodes associated with the specified root node. In the process of doing so, the following properties will be added to each node in your tree:

  • parent: the parent node, or null for the root.
  • children: the array of child nodes, or null for leaf nodes.
  • value: the node value, as returned by the value accessor.
  • depth: the depth of the node, starting at 0 for the root.
  • x: the minimum x-coordinate of the node position.
  • y: the minimum y-coordinate of the node position.
  • dx: the x-extent of the node position.
  • dy: the y-extent of the node position.

Authors and Contributors

Contributions are welcomed from anyone wanting to improve this project!

License & Copyright

deep-partition-layout is Copyright (c) 2015 NodeSource and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.