Rickshaw is a JavaScript toolkit for creating interactive real-time graphs.
Getting started with a simple graph is straightforward. Here's the gist:
var graph = new Rickshaw.Graph( {
element: document.querySelector('#graph'),
series: [
{
color: 'steelblue',
data: [ { x: 0, y: 23}, { x: 1, y: 15 }, { x: 2, y: 79 } ],
}, {
color: 'lightblue',
data: [ { x: 0, y: 30}, { x: 1, y: 20 }, { x: 2, y: 64 } ],
}
]
} );
graph.render();
-
element: a reference to an HTML element
-
series: an array of objects each with the following properties
- name: a name meant for humans
- color: a CSS color
- data: an array of objects, each with x and y properties
-
renderer: renderer name, like
stack
orline
-
width: width of the graph in pixels
-
height: height of graph in pixels
-
interpolation: optional line smoothing / interpolation method (see D3 docs); notable options:
- linear: straight lines between points
- step-after: square steps from point to point
- cardinal: smooth curves via cardinal splines (default)
- basis: smooth curves via B-splines
-
render(): paint the graph
-
setRenderer(): set renderer to stack or line
-
onUpdate(f): add a callback to run when the graph is rendered
-
Rickshaw.Graph.Legend - add a basic legend
-
Rickshaw.Graph.HoverDetail - show details on hover
-
Rickshaw.Graph.JSONP - get data via a JSONP request
-
Rickshaw.Graph.Annotate - add x-axis annotations
-
Rickshaw.Graph.RangeSlider - dynamically zoom on the x-axis with a slider
-
Rickshaw.Graph.Axis.Time - add x-axis time labels
-
Rickshaw.Graph.Behavior.Series.Highlight - highlight series on legend hover
-
Rickshaw.Graph.Behavior.Series.Order - reorder series in the stack with drag-and-drop
-
Rickshaw.Graph.Behavior.Series.Toggle - toggle series on and off through the legend
Rickshaw comes with a few color schemes. Instantiate a palette and specify a scheme name, and then call color() on the palette to get each next color.
var palette = new Rickshaw.Color.Palette( { scheme: 'spectrum2001' } );
palette.color() // => first color in the palette
palette.color() // => next color in the palette...
Available color schemes:
- classic9
- spectrum19
- spectrum2001
- spectrum2000
Rickshaw relies on the fantastic D3 visualization library to do lots of the heavy lifting for stacking and rendering to SVG.
Some extensions require jQuery and jQuery UI, but for drawing some basic graphs you'll be okay without.
For building, we need Node and npm. Running 'make' should get you going with any luck.
This library was developed by David Chester, Douglas Hunter, and Silas Sewell at Shutterstock
Copyright (C) 2011 by Shutterstock Images, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.