Skip to main content
100%

Reusable Chart Example

✓ Published0🌍 Public
Aapratt2003
Last edited Sep 28, 2017
Created on Sep 28, 2017

This example demonstrates small multiples of time-series charts using the reusable chart pattern from Mike Bostock's "Towards Reusable Charts" tutorial, updated to D3 v4. It renders monthly stock price data for multiple symbols as individual line and area charts, each with its own title, drawn in SVG. The chart instances share a global x-axis extent so their time axes align, while a `d3.nest` groups the data by symbol. Accessors for values, titles, and extents make the chart flexible and reusable.

AI-generated description

This example is a small multiples experiment based on code written by Mike Bostock in 2012 as part of his tutorial Towards Reusable Charts.

I had heard that the "Towards Reusable Charts" style can be used to easily create small multiples, but I didn't quite grok how. This example shows one way that it can work, drawing data and inspiration from this other example Small Multiples III. On the way, I upgraded the original reusable line chart code to D3 v4, with minimal modifications. I also wanted to add a title to each instance of the chart, so ended up adding the values and title accessors to make it work well with the output from d3.nest.

forked from <a href='http://bl.ocks.org/curran/'>curran</a>'s block: <a href='http://bl.ocks.org/curran/66d926fe73211fd650ec'>Towards Reusable Charts Example</a>

<!-- Start of SimpleHitCounter Code --> <div align="center"><img src="http://simplehitcounter.com/hit.php?uid=2227680&f=16777215&b=0" border="0" height="18" width="83"></div> <!-- End of SimpleHitCounter Code -->

forked from <a href='http://bl.ocks.org/curran/'>curran</a>'s block: <a href='http://bl.ocks.org/curran/02163a13a40112e0ab6f14bbacc986f8'>Small Multiples with Reusable Charts</a>

mit Licensed

Similar vizzes