alexpearce/histograms — pull request #9 by alexpearce (2014-06-05 16:31:30+00:00)
Title: Rewrite chart objects for simpler composition

This branch contains a substantial rewrite of the plots.

The main conceptual difference is that rather than having all the different plot types (Histogram, Histogram2D, scatter plots, etc.) derive from the `AxesChart` type, each plot is created as a new object called a `plotable`.

The idea is that on `AxesChart` is created, and then plots are added to it. The `AxesChart` is responsible for redrawing `plotables` contained within it, whilst each `plotable` is responsible for reporting the domain of the data within it and the drawing code.

An `AxesChart` is created the usual way, and then a `plotable` is created and added to the chart. This is the added advantage of making each plotable reusable, just add it to however many `AxesChart` instances as required.

```javascript
var chart = d3.select('#h1').chart('AxesChart')
.xAxisLabel('x')
.yAxisLabel('y');
var histogram = d3.plotable.Histogram('histo_title', data);
chart.addPlotable(histogram);
```

2D histograms are treated equally in this scheme, although currently the implementation does not deal nicely with the extra colour legend that's required; it just assume it's always needed so 1D histograms have a lot of spare space.