redux-devtools/packages/d3-state-visualizer
Nathan Bierema 5ef9b00cd4 Publish
- d3-state-visualizer@1.4.0
 - d3tooltip@1.3.0
 - devui@1.0.0-7
 - map2tree@1.5.0
 - react-json-tree@0.14.0
 - @redux-devtools/app@1.0.0-5
 - @redux-devtools/chart-monitor@1.8.0
 - @redux-devtools/cli@1.0.0-5
 - @redux-devtools/dock-monitor@1.3.0
 - redux-devtools-extension@2.13.9
 - @redux-devtools/inspector-monitor-test-tab@0.6.3
 - @redux-devtools/inspector-monitor-trace-tab@0.1.4
 - @redux-devtools/inspector-monitor@0.14.1
 - @redux-devtools/instrument@1.11.0
 - @redux-devtools/log-monitor@2.2.0
 - @redux-devtools/serialize@0.3.0
 - @redux-devtools/slider-monitor@2.0.0-6
 - @redux-devtools/utils@1.0.0-5
 - @redux-devtools/core@3.8.0
 - d3-state-visualizer-tree-example@0.1.0
 - react-json-tree-example@1.1.1
 - slider-todomvc@0.1.0
 - counter-redux@0.1.1
 - todomvc@0.2.0
2021-03-06 08:57:19 -05:00
..
examples/tree Publish 2021-03-06 08:57:19 -05:00
src chore(core): convert to TypeScript (#655) 2020-10-25 19:32:04 -04:00
.babelrc feat(d3-state-visualizer): convert to TypeScript (#640) 2020-09-20 19:05:37 -04:00
.eslintignore feat(d3-state-visualizer): convert to TypeScript (#640) 2020-09-20 19:05:37 -04:00
.eslintrc.js feat(d3-state-visualizer): convert to TypeScript (#640) 2020-09-20 19:05:37 -04:00
CHANGELOG.md Publish 2021-03-06 08:57:19 -05:00
LICENSE.md chore(*): add back license files (#578) 2020-08-09 01:11:43 -04:00
package.json Publish 2021-03-06 08:57:19 -05:00
README.md chore(*): upgrade prettier (#570) 2020-08-08 16:26:39 -04:00
tsconfig.json feat(d3-state-visualizer): convert to TypeScript (#640) 2020-09-20 19:05:37 -04:00
tsconfig.webpack.json feat(d3-state-visualizer): convert to TypeScript (#640) 2020-09-20 19:05:37 -04:00
webpack.config.umd.ts feat(d3-state-visualizer): convert to TypeScript (#640) 2020-09-20 19:05:37 -04:00

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,
  style: { 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
style 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...

## Bindings

React

example implementation.

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.