Skip to main content
100%

Towards_Updateable-Resusable-ProD3js_d3jsCharts

✓ Published1🌍 Public
JJimMaltby
Last edited Nov 23, 2021
Created on Nov 23, 2021

This example demonstrates a reusable and updateable bar chart built with D3.js v5, following the patterns from Mike Bostock’s "Towards Reusable Charts" and Rob Moore’s "Towards Updatable" approach. It renders SVG rectangles scaled from an array of numerical data, with smooth transitions for updating bar dimensions, colors, and datasets. The chart exposes getter-setter methods for `width`, `height`, `fillColor`, and `data` that trigger animated updates via `transition().duration()`. New bars fade in while exiting bars shrink and fade out, all rendered in a vanilla HTML page with multiple chart containers.

AI-generated description

Simple Bar Chart example:

A vanilla HTML implementation of Rob Moores updateable pattern Towards Updatable https://www.toptal.com/d3-js/towards-reusable-d3-js-charts.

It is derived from Mike Bostock's Towards Reusable Charts (https://bost.ocks.org/mike/chart/) as the source of the foundational principles.

Will evolve to use the ProD3 pattern (Pro D3.js Use D3.js to Create Maintainable, Modular, and Testable Charts by Marcos Iglesias https://www.apress.com/gp/book/9781484252024) as the basis for further charts.

MIT Licensed

Similar vizzes