Fork of Fork of Butter Macronutrients
A reusable D3.js v7 bar chart demonstrates how a chart function can render and update between two datasets. The visualization displays categorical labels on the x-axis and numeric values on the y-axis, with color-coded bars for each category. A button click triggers a toggle between the two sample datasets, clearing the existing SVG and re-rendering with the new data. The code uses D3 scales (`scaleBand` and `scaleLinear`), axis generators (`axisLeft`, `axisBottom`), and selection methods to build the SVG chart programmatically.