Working on D3 visualisation tool
Renders: D3, PNG, Illustrator compatible SVG
http://blog.safaribooksonline.com/2013/07/11/reusable-d3-js-using-attrtween-transitions-and-mv/
Not instantly reusable.
Hopefully more reusable.
Build modules, components, managers.
Encapsulation is the model.
Not an unwieldy hierarchy of objects.
A module: "A reusable piece of code"
A component: "A reusable piece of code generating graphics, which doesn't represent a complete chart, but a part meant to be composed with other elements"
Good example of a component: d3.svg.axis
/src/svg/axis.js
Mike Bostock: Towards Reusable Charts
http://bost.ocks.org/mike/chart/JavaScript Closures
Code within exports, has access to priv1 and priv2.
Component Structure
Using a Component:
https://bl.ocks.org/cloudshapes/6003578
Simplified example from the book.
Component Structure Revisited
https://bl.ocks.org/cloudshapes/5909708
https://bl.ocks.org/cloudshapes/5909708
https://bl.ocks.org/cloudshapes/5909708
Events, particularly use of d3.dispatch, play a key part in co-ordinating code.
The "ministers" app uses a similar, except more developed structure:
(via Chris Viau, Andrew Thornton):
(via Chris Viau, Andrew Thornton):
The simplified pattern is essentially:
(via Chris Viau, Andrew Thornton):
Chris Viau example: https://bl.ocks.org/biovisualize/5372077
Talks re: using the reusable API with MV* framework (involving Chris Viau):
40% Discount URL for the D3 Book: https://gumroad.com/l/vyYr/$8discount