2.6.0 • Published 9 years ago

react-circletree v2.6.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

react-circletree

A circle tree component for React applications

Get the component

npm install react-circletree --save

Use the component

If you're using an ES6-capable build system, simply use react-circletree:

var CircleTree = require('react-circletree');

Or if you're using an ES5 build system:

var CircleTree = require('react-circletree/es5');

An example app

See the exampleapp for an example

API

<CircleTree
  radius={number: width of each segment, defaults to 80}
  spacing={number: spacing between segments, defaults to 3}
  leafRadius={number: width of each leaf segment, defaults to 7},
  leafSpacing={numbe: spacing between leaves in a leaf stack, defaults to 2}
  data={object: nested, keyed data. Leaf stacks encoded as arrays}
  onToggle={function: see note below, no default}
/>

For an example of data, see this object.

passing a onToggle() handler

As segments in the circle tree can be clicked, you might want to do something based on that interaction.

As such, passing a onToggle function as a property to the <CircleTree> component will give you a way to know what the user clicked:

  ...
  onToggle(labels) {
    // labels is an array of all the applicable labels in the chain
    // from the tree's root to the segment that was clicked by the
    // user. As such, labels[0] is always the root label, and
    // labels.slice(-1)[0] is always the segment the user clicked.
  },
  ...
  render() {
    return <CircleTree onToggle={this.onToggle}/>
  },
  ...

Demo

https://pomax.github.io/react-circletree

2.6.0

9 years ago

2.5.0

9 years ago

2.4.0

9 years ago

2.3.1

9 years ago

2.3.0

9 years ago

2.2.0

10 years ago

2.1.0

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago