Modular ReactJS charts made using d3 chart utilities.
Caution: alpha state software. Chart APIs will change.
The basic charts generated from the examples/main.js ReactJS app can be viewed here. Additional chart types and chart animations are soon to come.
First, install via
npm install react-d3
Then, import into your ReactJS project:
var rd3 = require('react-d3');
The charts are then available under the
rd3 namespace, which you can then use as shown on the demonstration page.
There's a development build available for experimentation on JSFiddle: http://jsfiddle.net/esbullington/jp9dkh1g/
Please note that this build should probably not be used in production, since it bundles all of react-d3's dependencies in a single bundle (this is also the cause of the "Cannot read property 'firstChild' of undefined" error message on the JS console, which occurs when there are two React libraries in the same namespace).
All the react-d3 charts are available in this JSFiddle fork under the global
Although there have been several different approaches proposed for combining the power of d3 with the flexibility and modularity of ReactJS, the approach I'm using here was inspired by this blog post by Ben Smith of Binary Consulting. Basically, it uses React to generate a chart's svg components using stateless React components.
With this approach, ReactJS itself is responsible for the SVG markup. d3 is used for its tremendous collection of utility functions, such as those that calculate the
path value for various chart types.
However, I've diverged a bit from this original vision and am storing a bit of state in top-level chart components in order to leverage d3's axis generators, at least until I develop native React chart axes.
Copyright (c) 2014 Eric. S Bullington