Untitled
This example shows how bar charts can compare values for two groups, Female and Male, across three different time periods (2008, 2012, 2016) using interactive buttons. The chart displays the data as blue bars, with the y-axis scaled to the maximum value of the current dataset. The code uses d3.v6 to create an SVG, with `d3.scaleBand` for the x-axis, `d3.scaleLinear` for the y-axis, and transitions of 1000 milliseconds to animate updates between datasets. The `update` function binds data to rectangles, merges enter and update selections, and removes exiting bars.