Skip to main content
100%

Color and Size Legends - Component Experiment

✓ Published0🌍 Public
NNilla
Last edited Mar 27, 2019
Created on Mar 27, 2019

This example demonstrates two reusable legend components that visualize ordinal color scales and quantitative size scales using SVG rendering. The color legend displays fruit categories as colored circles, while the size legend uses d3.scaleSqrt to encode numeric values through varying circle radii. Both components are implemented as functions that receive configuration through property assignment, following the reusable chart pattern. The code uses d3.scaleOrdinal, d3.scaleSqrt, selection.merge, and selection.call to update and render the legends dynamically.

AI-generated description

An experiment in passing parameters into "components" by setting properties on the component functions. This is closer to the Towards Reusable Charts pattern, in that you can set state once and invoke the component elsewhere. With this approach you can't tap into the getters and setters though.

MIT Licensed

Similar vizzes