UNPKG

2.01 kBMarkdownView Raw
1d3-state-visualizer
2===================
3Enables real-time visualization of your application state. [Demo](http://romseguy.github.io/d3-state-visualizer)
4
5## Installation
6
7`npm install d3-state-visualizer`
8
9## Usage
10
11```javascript
12import { charts } from 'd3-state-visualizer';
13
14const appState = {
15 todoStore: {
16 todos: [
17 { title: 'd3'},
18 { title: 'state' },
19 { title: 'visualizer' },
20 { title: 'tree' }
21 ],
22 completedCount: 1
23 }
24};
25
26const render = charts.tree(document.getElementById('root'), {
27 state: appState,
28 id: 'treeExample',
29 size: 1000,
30 aspectRatio: 0.5,
31 isSorted: false,
32 widthBetweenNodesCoeff: 1.5,
33 heightBetweenNodesCoeff: 2,
34 style: {border: '1px solid black'},
35 tooltipOptions: {offset: {left: 30, top: 10}, indentationSize: 2}
36});
37
38render();
39```
40
41## Bindings
42
43View components are now provided along with the charts, but it makes sense to have different repositories if this project gets some attention.
44
45### Plain React
46
47[TreeChart](https://github.com/romseguy/d3-state-visualizer/blob/master/src/components/TreeChart.js) component.
48
49```javascript
50import { components } from 'd3-state-visualizer'
51
52const { TreeChart } = components;
53const options = {
54 id: 'chartSvgId',
55 size: 1000,
56 aspectRation: 0.5,
57 heightBetweenNodesCoeff: 1,
58 widthBetweenNodesCoeff: 1.5,
59 style: {float: 'left'},
60 tooltipOptions: {left: 0, top: 0, indentationSize: 2}
61};
62
63class MyApp extends React.Component {
64 render() {
65 return (
66 <div>
67 <TreeChart state={this.props.state} ...options />
68 <Container/>
69 </div>
70 );
71 }
72}
73```
74
75[example](https://github.com/romseguy/d3-state-visualizer/tree/master/examples/react-tree) implementation.
76
77## Roadmap
78
79* Provide more components such as `DockedTreeChart`
80* Search box to filter the tree down
81* Panning/zooming features for large state trees
82* 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.