Clustered Bar Chart - Average Insurance Charges by Region
This clustered bar chart displays average insurance charges across four US regions, comparing smokers (red bars) versus non-smokers (black bars) using data from an Insurance Expenses Dataset. The visualization uses D3 v6 scales—`scaleBand` for the region groups and subgroup categories, `scaleLinear` for the y-axis, and `scaleOrdinal` for color mapping. Data is loaded via `d3.csv` and grouped with a custom `groupBy` function that calculates averages by smoking status. The SVG rendering includes axis generators (`axisBottom`, `axisLeft`) and a custom legend, with bars shaded at 0.95 opacity.
AI-generated descriptionA clustered bar chart using D3 displaying data of insurance charges from the Insurance Expenses Dataset.
The region where the customers live is displayed on the x-axis, the average insurance charges in dollars on the y-axis and their smoking status on the color of the bars (black if they don't smoke or red if they do).