block by emeeks 02d6acaed240ba0a504e

Simple Difference Chart with d3.svg.area

Full Screen

A difference chart of presidential approval ratings of the Obama and Bush (43) administrations. Difference charts graphically encode the variance between two time series (typically) coloring the variance to indicate which time series has a higher value during that period. All the examples I’ve seen of difference charts in D3 use clipping or convoluted mechanisms to create the difference area.

Here’s an example that just uses d3.svg.area and defines the y value as the maximum of the two time series points at that position and the y0 value as whichever time series you’re using as the baseline. To give the chart the expected outlines, d3.svg.line is used to draw each time series on top of the difference areas.

This chart was used in my exploration of figure/ground and metastability in data visualization.

index.html

bush_obama.json