• Stars
    star
    6,540
  • Rank 5,754 (Top 0.2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 12 years ago
  • Updated about 1 year ago

Reviews

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

Repository Details

JavaScript toolkit for creating interactive real-time graphs

NPM version Build Status Coverage Status

Rickshaw

Rickshaw is a JavaScript toolkit for creating interactive time series graphs, developed at Shutterstock

Table of Contents

Getting Started

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();

See the overview, tutorial, and examples for more.

Install

In the browser, manually add rickshaw.min.js and rickshaw.min.css in the document head.

Alternatively, you can install Rickshaw using Bower or npm.

# With bower
bower install rickshaw
# With npm
npm install --save rickshaw

Dependencies

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.

Rickshaw uses jsdom to run unit tests in Node to be able to do SVG manipulation. As of the jsdom 7.0.0 release, jsdom requires Node.js 4 or newer jsdom changelog. If you want to run the tests on your machine, and you don't have access to a version of node >= 4.0, you can npm install jsdom@3 so that you can run the tests using the 3.x branch of jsdom.

Rickshaw.Graph

A Rickshaw graph. Send an element reference, series data, and optionally other properties to the constructor before calling render() to point the graph. A listing of properties follows. Send these as arguments to the constructor, and optionally set them later on already-instantiated graphs with a call to configure()

element

A reference to an HTML element that should hold the graph.

series

Array of objects containing series data to plot. Each object should contain data at a minimum, a sorted array of objects each with x and y properties. Optionally send a name and color as well. Some renderers and extensions may also support additional keys.

renderer

A string containing the name of the renderer to be used. Options include area, stack, bar, line, and scatterplot. Defaults to line. Also see the multi meta renderer in order to support different renderers per series.

width

Width of the graph in pixels. Falls back to the width of the element, or defaults to 400 if the element has no width.

height

Height of the graph in pixels. Falls back to the height of the element, or defaults to 250 if the element has no height.

min

Lower value on the Y-axis, or auto for the lowest value in the series. Defaults to 0.

max

Highest value on the Y-axis. Defaults to the highest value in the series.

padding

An object containing any of top, right, bottom, and left properties specifying a padding percentage around the extrema of the data in the graph. Defaults to 0.01 on top for 1% padding, and 0 on other sides. Padding on the bottom only applies when the yMin is either negative or auto.

interpolation

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
stack

Allows you to specify whether series should be stacked while in the context of stacking renderers (area, bar, etc). Defaults to stack: 'true'. To unstack, unstack: 'true'.

Methods

Once you have instantiated a graph, call methods below to get pixels on the screen, change configuration, and set callbacks.

render()

Draw or redraw the graph.

configure()

Set properties on an instantiated graph. Specify any properties the constructor accepts, including width and height and renderer. Call render() to redraw the graph and reflect newly-configured properties.

onUpdate(f)

Add a callback to run when the graph is rendered

Extensions

Once you have a basic graph, extensions let you add functionality. See the overview and examples listing for more.

  • 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.RangeSlider.Preview - pan and zoom via graphical preview of entire data set

  • Rickshaw.Graph.Axis.Time - add an x-axis and grid lines with time labels

  • Rickshaw.Graph.Axis.X - add an x-axis and grid lines with arbitrary labels

  • Rickshaw.Graph.Axis.Y - add a y-axis and grid lines

  • Rickshaw.Graph.Axis.Y.Scaled - add a y-axis with an alternate scale

  • 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.Color.Palette

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...

Optionally, to palette.color() can take a numeric argument to specify which color from the palette should be used (zero-indexed). This can be helpful when assigning a color to series of a plot with particular meaning:

var palette = new Rickshaw.Color.Palette( { scheme: 'colorwheel' } );

palette.color(0) // => first color in the palette - red in this example
palette.color(2) // => third color in the palette - light blue

Color Schemes

  • classic9
  • colorwheel
  • cool
  • munin
  • spectrum14
  • spectrum2000
  • spectrum2001

Interpolation

For graphs with more series than palettes have colors, specify an interpolatedStopCount to the palette constructor.

Rickshaw and Cross-Browser Support

This library works in modern browsers and Internet Explorer 9+.

Rickshaw relies on the HTMLElement#classList API, which isn't natively supported in Internet Explorer 9. Rickshaw adds support by including a shim which implements the classList API by extending the HTMLElement prototype. You can disable this behavior if you like, by setting RICKSHAW_NO_COMPAT to a true value before including the library.

Minification

If your project uses minification, you will need to give a hint to the minifier to leave variables named $super named $super. For example, with uglify on the command line:

$ uglify-js --reserved-names "$super" rickshaw.js > rickshaw.min.js

Or a sample configuration with grunt-contrib-uglify:

uglify: {
  options: {
    mangle: { except: ["$super"] }
  }
}

Development

For building, we use Node and npm. Running npm run build or make should get you going with any luck.

After doing a build you can run the tests with the command: npm test

For more availible options see the package.json scripts section.

Contributing

Pull requests are always welcome! Please follow a few guidelines:

  • Please don't include updated versions of rickshaw.js and rickshaw.min.js. Just changes to the source files will suffice.
  • Add a unit test or two to cover the proposed changes
  • Do as the Romans do and stick with existing whitespace and formatting conventions (i.e., tabs instead of spaces, etc)
  • Consider adding a simple example under examples/ that demonstrates any new functionality

Please note that all interactions with Shutterstock follow the Contributor Covenant Code of Conduct.

Authors

This library was developed by David Chester, Douglas Hunter, and Silas Sewell at Shutterstock

License

Copyright (C) 2011-2020 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.

More Repositories

1

node-common-errors

Common error classes and utility functions
JavaScript
284
star
2

lil-brother

Track clicks and other client-side events on web pages
JavaScript
223
star
3

changeDPI

Javascript library that allows you to change an image's DPI settings in the browser
JavaScript
203
star
4

ntf

Network Testing Framework
JavaScript
98
star
5

basecoat

A small, fast, static free micro framework that makes no assumptions and requires no conventions. It is well suited for migrating off legacy code, building services, or complex websites.
PHP
42
star
6

shutterstock-heatmap-toolkit

Shutterstock's interactive heatmap toolkit powered by heatmap.js and Solr
JavaScript
36
star
7

api-clients-examples

Shutterstock API Clients and Examples
32
star
8

armrest

A high-level HTTP / REST client for Node
JavaScript
29
star
9

gremlin-aws-sigv4

Extension for Apache's TinkerPop3 Gremlin JS driver compatible with IAM Database Authentication for Neptune
JavaScript
29
star
10

fnFlow

Pronounced "effin' flow" because it's so badass, fnFlow is a Javascript control flow library heavily influenced by Caolan McMahon's async that encourages a proper functional design pattern.
JavaScript
21
star
11

postcss-copy-assets

PostCSS plugin to copy assets referenced by relative url()s into a build directory.
JavaScript
18
star
12

opentree

Generate an Org Chart from Workday
Java
18
star
13

public-api-javascript-sdk

Simplify and speed up integration by using a JavaScript library to access our API.
JavaScript
17
star
14

node-procedural-async

Write procedural style code that runs asynchronously. It may look synchronous, but it's not!
JavaScript
17
star
15

UrlManager

Javascript class for getting and setting url parameters
JavaScript
15
star
16

tungsten-replicator

Shutterstock git mirror of Tungsten Replicator.
Java
14
star
17

juxtaposer

Screen shot capture and comparison tool for testing website changes.
JavaScript
14
star
18

kafkajs-async-retry

Provides a KafkaJS-compatible handler for processing messages that facilitates publishing to delayed-retry or dead-letter topics
TypeScript
12
star
19

ntfserver

Network Testing Framework Server
JavaScript
11
star
20

terraform-aws-s3-squid-proxy-farm

AWS Terraform module to create an S3 Squid proxy farm on AWS
HCL
10
star
21

task

Task-based git release management
Perl
10
star
22

node-shutterstock-api

⛔️ DEPRECATED - A client for the Shutterstock API written in Node
JavaScript
9
star
23

presto

PHP REST Orchestration
PHP
8
star
24

ruby-shutterstock-api

⛔️ DEPRECATED - Ruby client for Shutterstock public API
Ruby
7
star
25

node-favicon-video

Videos in your favicon!
JavaScript
7
star
26

php-shutterstock-api

PHP Client to interact with the Shutterstock API
PHP
7
star
27

orc-metadata-reader

Python ORC metadata reader
C
7
star
28

Data-Partial-Google

Filter data structures for "partial responses," Google style
Perl
6
star
29

welcome

Welcome to the Shutterstock Community
6
star
30

shutterstock-cli

A command-line utility that allows you to interact with the Shutterstock public API.
Python
5
star
31

oplog

An operations log
JavaScript
5
star
32

devent-router

Route Devent messages by topic
C
5
star
33

node-timing-middleware

Expose request timing in express apps
JavaScript
5
star
34

SVC

MVC for javascript with the observer pattern
JavaScript
5
star
35

public-api-sdk-generator

Mustache
4
star
36

shutterstock-oauth-sample

⛔️ DEPRECATED - Shutterstock Oauth Sample code, for interacting with the Shutterstock API
JavaScript
4
star
37

devent-forwarder

Forward Devent messages via HTTP, UDP or ZMQ
JavaScript
4
star
38

spark-phrases

phrase detection using Google's Word2phrase
Scala
4
star
39

php-shutterstock-api-example

Example PHP application that interfaces with Shutterstock API
PHP
3
star
40

node-icu-numformat

Node.JS bindings to libicu number formatting functions
C++
3
star
41

MogileFS-Plugin-Migrate

MogileFS plugin for moving files across domains
Perl
3
star
42

astore

Shared request aggregator and temp entity store
JavaScript
3
star
43

gitbook-plugin-related-links

Gitbook plugin that collects and shows related links
JavaScript
3
star
44

go-stockutil

A collection of various useful utility functions for Golang applications
Go
3
star
45

wordpress-plugin

PHP
2
star
46

Stemming-Exceptions

A collection of stemming exceptions for different languages.
2
star
47

perl-moosex-role-rest-consumer

Perl
2
star
48

Net-Statsd-Client

Perl
2
star
49

newrelic-console-logging

Forwards all logs emitted through console.log (and friends) to New Relic's application logging aggregation endpoint.
JavaScript
2
star
50

a-swig-service

A service that well, serves html from swig templates
JavaScript
2
star
51

ntfd

Network Testing Framework Daemon
JavaScript
2
star
52

Webdam-Wordpress-Asset-Chooser

Webdam Wordpress Asset Chooser Plugin
PHP
2
star
53

bigstock-php-client

⛔️ DEPRECATED - PHP Client for the Bigstock API
PHP
2
star
54

api-php-client

⛔️ DEPRECATED - Sample PHP client implementation of Shutterstock API
PHP
2
star
55

bigstock-ruby-client

⛔️ DEPRECATED - A Ruby client for Bigstock's API
Ruby
1
star
56

bristlecone

A set of test tools that perform useful services for measuring database and database cluster performance
Java
1
star
57

perl-devent-client

Perl client for writing Devent messages
Perl
1
star
58

homebrew-shutterstock

Homebrew tap for Shutterstock
Ruby
1
star
59

shutterstock-ui-wizard

HTML
1
star
60

shutterstock-js-cli

Shutterstock in your /usr/bin
JavaScript
1
star
61

http-close-channel

Express middleware for managing and closing HTTP channels
JavaScript
1
star
62

mold

JavaScript
1
star
63

node-debug-middleware

Log all middleware that is slow to respond
JavaScript
1
star
64

perl-webservice-swigclient

A fast client for swig.io
Perl
1
star
65

p-map-iterable

Performs a concurrent mapping with back pressure (won't iterate all source items if the consumer is not reading).
TypeScript
1
star
66

Tree-SEMETrie

Single-Edge-Multi-Edge Trie
Perl
1
star
67

perl-db-transaction

feather-weight transaction management for your DBI handles
Perl
1
star
68

vertica-cli

Command-line Vertica client in Node.js
JavaScript
1
star
69

WebService-Shutterstock

⛔️ DEPRECATED - Easy access to Shutterstock's public API
Perl
1
star
70

bigstock-node-client

⛔️ DEPRECATED - A node.js client to use with Bigstock, an easy-to-use marketplace for stock images.
JavaScript
1
star