palantir/plottable — pull request #281 by danmane (2014-04-11 23:56:48+00:00)
Title: 0.8.0 refactor renderer

Some terminology Justin and I came up with:
First, there is data.
Then, we use accessors to get a particular view into the data, which is called a "Perspective"
Then, we use scales to map that perspective into some drawable property, which is called a "Projection".
Renderers draw these projections onto the screen.

In this refactor, we replace custom xAccessor, yAccessor setters on renderers and other ad hoc methods with a Renderer.projector method which takes an attribute to project onto (eg "cx" or "stroke"), an accessor function to get the perspective out of the data source, and (optionally) a scale to project the data through.

This generalizes the API considerably because now all attributes of the svg can be changed without hardcoded support in the renderer.

It also will enable the scale autodomain refactor, wherein scales will keep track of the perspectives that back them. This means that scales can autodomain themselves in the general case, not just with hardcoded support. (Whereas in the past we would have custom logic for xScale and yScale to autodomain, but color scales or radius scales or what-have-you were left out.)

Also, it means scales can maintain a source of truth for what span they need to cover and can also handle padding and nice-ing in an intelligent way.