Skip to main content
100%

Composable Visualization Test

✓ Published0🌍 Public
CCurran Kelleher
Last edited Apr 28, 2016
Created on Apr 27, 2016

This example demonstrates the concept of composable visualization components using D3.js, where a `Rect` component is nested within a `FacetVertical` component to create vertically stacked small multiples. The code defines each component as a function with configurable properties such as `width`, `height`, `color`, and `nestBy`, then composes them via a `compose` method. Rendering to an SVG canvas, the `FacetVertical` component partitions the data by name into separate groups, and the `Rect` component draws colored rectangles using a category10 color scale. The data consists of a simple array of three objects with a `name` attribute.

AI-generated description

This is an experiment with the notion of composable visualization components that follow the Towards Reusable Charts pattern (which I think I'm finally grokking after all these years).

The idea is that visualization components can be composed in kind of a recursive way. This would make it straightforward to create, say, stacked bar charts by simply composing components in an almost algebraic expression like barChart * verticalStack * rect. Making that into small multiples would simply require the addition of a facet component to the expression: facetVertical * barChart * verticalStack * rect.

concept

This kind of thing is present in the Grammar of Graphics, the ggplot2 paper, and Vega. It would be amazing to discover straightforward JavaScript/D3 patterns that enable this kind of thing.

Built with blockbuilder.org

<!-- Start of SimpleHitCounter Code --> <div align="center"><img src="http://simplehitcounter.com/hit.php?uid=2095999&f=16777215&b=0" border="0" height="18" width="83" alt="diaper cake"></div> <!-- End of SimpleHitCounter Code -->

Similar vizzes