Skip to main content
100%

Margin Convention with ReactiveModel

✓ Published0🌍 Public
CCurran Kelleher
Last edited Jun 13, 2016
Created on Apr 16, 2016

This example demonstrates the Margin Convention pattern for SVG charts, where a gray rectangle represents the inner plotting area within configurable top, bottom, left, and right margins. It shows how margins respond dynamically both to browser resizing and to a continuous animation that varies each margin sinusoidally. Built on D3 v4 and the ReactiveModel library, the visualization uses reactive model declarations to update SVG attributes such as `width`, `height`, `transform`, and rectangle dimensions whenever their input variables change. The code appends an SVG via `d3.select` and uses `requestAnimationFrame` to drive the margin animation loop.

AI-generated description
<p align="center"> <img src="https://cloud.githubusercontent.com/assets/68416/15611401/d2a2f8ca-2447-11e6-82f8-61701f43d49e.png"> <br> The data flow graph for this example (made with <a href="https://github.com/datavis-tech/graph-diagrams">graph-diagrams</a>). </p>

This example shows dynamic margins for data visualizations using D3 4.0 and ReactiveModel. To experience the resize behavior, run this example full-screen and resize the browser. Based on the original D3 example Margin Convention. Part of a series of examples demonstrating ReactiveModel.

forked from <a href='http://bl.ocks.org/curran/'>curran</a>'s block: <a href='http://bl.ocks.org/curran/974c9def890f8ac0172611921fb51b8a'>Responding to Resize with ReactiveModel</a>

forked from <a href='http://bl.ocks.org/curran/'>curran</a>'s block: <a href='http://bl.ocks.org/curran/2c736a99c2f57bfac7e4'>Margin Convention with Model.js</a>

Built with blockbuilder.org

<!-- Start of SimpleHitCounter Code --> <div align="center"><a href="http://www.simplehitcounter.com" target="_blank"><img src="http://simplehitcounter.com/hit.php?uid=2073272&f=16777215&b=0" border="0" height="18" width="83" alt="web counter"></a></div> <!-- End of SimpleHitCounter Code -->
mit Licensed

Similar vizzes