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-state-visualizer

v3.0.0

Published

Visualize your app state with a range of reusable charts

Downloads

24,532

Readme

d3-state-visualizer

Enables real-time visualization of your application state.

Created by @romseguy and merged from reduxjs/d3-state-visualizer.

Demo

Installation

yarn install d3-state-visualizer

Usage

import { tree } from 'd3-state-visualizer';

const appState = {
  todoStore: {
    todos: [
      { title: 'd3' },
      { title: 'state' },
      { title: 'visualizer' },
      { title: 'tree' },
    ],
    completedCount: 1,
  },
};

const render = tree(document.getElementById('root'), {
  state: appState,
  id: 'treeExample',
  size: 1000,
  aspectRatio: 0.5,
  isSorted: false,
  widthBetweenNodesCoeff: 1.5,
  heightBetweenNodesCoeff: 2,
  chartStyles: { border: '1px solid black' },
  tooltipOptions: { offset: { left: 30, top: 10 }, indentationSize: 2 },
});

render();

Charts API

The APIs are minimal and consists of a single function you provide with:

  • a DOM element
  • a plain old JS object for options.

Tree

This chart is a bit special as it accepts either one of the two following options, but not both:

  • tree: a properly formed tree structure such as one generated by map2tree or react2tree
  • state: a plain javascript object mapping arbitrarily nested keys to values – which will be transformed into a tree structure, again using map2tree.

Other options are listed below and have reasonable default values if you want to omit them:

| Option | Type | Default | Description | | ------------------------- | ------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | id | String | 'd3svg' | Sets the identifier of the SVG element —i.e your chart— that will be added to the DOM element you passed as first argument | | chartStyles | Object | {} | Sets the CSS style of the chart | | size | Number | 500 | Sets size of the chart in pixels | | aspectRatio | Float | 1.0 | Sets the chart height to size * aspectRatio and viewBox in order to preserve the aspect ratio of the chart. Great video if you want to learn more about how SVG works | | widthBetweenNodesCoeff | Float | 1.0 | Alters the horizontal space between each node | | heightBetweenNodesCoeff | Float | 1.0 | Alters the vertical space between each node | | isSorted | Boolean | false | Sorts the chart in alphabetical order | | transitionDuration | Number | 750 | Sets the duration of all the transitions used by the chart | | tooltipOptions | Object | here | Sets the options for the tooltip that is showing up when you're hovering the nodes | | rootKeyName | String | 'state' | Sets the first node's name of the resulting tree structure. Warning: only works if you provide a state option | | pushMethod | String | 'push' | Sets the method that shall be used to add array children to the tree. Warning: only works if you provide a state option |

More to come...

Roadmap

  • Threshold for large arrays so only a single node is displayed instead of all the children. That single node would be exclude from searching until selected.