Skip to main content
100%

D3 bar chart with data-binding

✓ Published0🌍 Public
CCtuauden
Last edited Jan 19, 2018
Created on Jan 19, 2018

This D3 v4 bar chart demonstrates interactive data-binding by rendering an SVG with rectangles sized from a hardcoded array of numbers. The chart uses `d3.scaleLinear` for the y-axis and `d3.scaleBand` for the x-axis, with bars turning red on mouse hover and green on click, while retaining the green color after the click via a custom `__clicked` property. The example, forked from romsson's block, differs from its non-binding predecessor by applying D3's `selectAll` and `.data()` method to attach data to shapes, enabling direct event handlers that reference each data value.

AI-generated description

Built with blockbuilder.org

forked from <a href='http://bl.ocks.org/romsson/'>romsson</a>'s block: <a href='http://bl.ocks.org/romsson/f4baa95d363ee21d0952ca561cd2a0e5'>D3 bar chart without data-binding</a>

forked from <a href='http://bl.ocks.org/anonymous/'>anonymous</a>'s block: <a href='http://bl.ocks.org/anonymous/2d2914cbd2482f4a29281798cd60394d'>D3 bar chart with data-binding</a>

forked from <a href='http://bl.ocks.org/anonymous/'>anonymous</a>'s block: <a href='http://bl.ocks.org/anonymous/9777d31afaa5df3e7512757f3dc5c887'>D3 bar chart with data-binding</a>

forked from <a href='http://bl.ocks.org/romsson/'>romsson</a>'s block: <a href='http://bl.ocks.org/romsson/e7aeedeb03300f4cdfd54531e33e9b68'>D3 bar chart with data-binding</a>

mit Licensed

Similar vizzes