• This repository has been archived on 05/Aug/2020
  • Stars
    star
    103
  • Rank 321,328 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Real-time visualizations of your application state

d3-state-visualizer

This package was merged into the redux-devtools monorepo. Please refer to that repository for the latest updates, issues and pull requests.

Enables real-time visualization of your application state.

Demo

Installation

npm 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

### Redux Dev tools

See this repository.

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.

More Repositories

1

redux

A JS library for predictable global state management
TypeScript
60,403
star
2

react-redux

Official React bindings for Redux
TypeScript
23,176
star
3

reselect

Selector library for Redux
TypeScript
18,988
star
4

redux-thunk

Thunk middleware for Redux
TypeScript
17,731
star
5

redux-devtools

DevTools for Redux with hot reloading, action replay, and customizable UI
TypeScript
13,863
star
6

redux-toolkit

The official, opinionated, batteries-included toolset for efficient Redux development
TypeScript
10,289
star
7

redux-mock-store

A mock store for testing Redux async action creators and middleware.
JavaScript
2,490
star
8

redux-templates

Official Redux templates for Vite, Create-React-App, and more
TypeScript
1,309
star
9

cra-template-redux

ARCHIVED: the CRA+JS template has moved to https://github.com/reduxjs/redux-templates
JavaScript
1,266
star
10

redux-devtools-chart-monitor

A chart monitor for Redux DevTools https://www.npmjs.com/package/redux-devtools-chart-monitor
JavaScript
292
star
11

redux-essentials-example-app

Example app for the Redux Essentials tutorial
CSS
287
star
12

rtk-github-issues-example

Source code for the Redux Toolkit Advanced Tutorial
TypeScript
211
star
13

rtk-convert-todos-example

Source code for the Toolkit Intermediate Tutorial
JavaScript
91
star
14

redux-fundamentals-example-app

Example app for the Redux Fundamentals tutorial
CSS
77
star
15

react-redux-benchmarks

Performance benchmark harness for React-Redux
TypeScript
69
star
16

redux-essentials-counter-example

The standard Redux / Redux Toolkit "counter" app template for Create React App
JavaScript
44
star
17

examples

Examples of how to use Redux.
JavaScript
40
star