🌍 Public
Viewing a saved revision (read-only)
5d7f9af6ac614056add6761560a08a09
React Starter
A React component hierarchy wraps D3-generated SVG axes and rectangles to render a horizontal bar chart from a hardcoded object of key-value pairs. The chart maps object keys to an ordinal y-axis via `d3.scaleBand` and values to a linear x-axis via `d3.scaleLinear`, with `d3.axisLeft` and `d3.axisBottom` for ticks. Bars are drawn as SVG `rect` elements that change fill color on click. The code imports `d3` v5 and uses React refs to attach D3 selections within `componentDidMount` and `componentDidUpdate` lifecycle methods.
AI-generated descriptionReact Starter code.