Skip to main content
100%

Reusable Chart Example

✓ Published0🌍 Public
TThanaporn-sk
Last edited Apr 22, 2017
Created on Mar 9, 2017

This example demonstrates a reusable chart pattern by rendering small multiples of monthly stock price data for the S&P 500 and MSFT from a TSV file. Each chart displays an area and line graph with a shared x-axis extent, using D3 v4’s `d3.nest`, `d3.scaleTime`, `d3.scaleLinear`, and SVG paths. The `timeSeriesChart` function exposes accessors like `values` and `title` to customize per-instance data and labels, following Mike Bostock’s “Towards Reusable Charts” tutorial.

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