Skip to main content
100%

Fork of Color and Size Legends - Component Experiment

✓ Published0🌍 Public
AAnthony Zornig
Last edited Oct 17, 2021
Created on Oct 17, 2021

This fork of the D3.js legend component experiment passes parameters into chart functions by assigning properties directly onto the functions themselves, following the reusable charts pattern. It renders an SVG with two legends: a color legend using `d3.scaleOrdinal` for fruit categories and a size legend built with `d3.scaleSqrt` for numeric ticks. The code uses `selection.call()` to invoke each component, with styles defined in CSS for tick text and circle strokes.

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