Skip to main content
100%

Refactor bar chart

✓ Published1🌍 Public
Ssurikmeetr
Last edited Mar 9, 2021
Created on Mar 9, 2021

This example displays a horizontal bar chart of population data for the top 10 countries from a UN 2019 dataset, rendered as SVG elements within a React component. The code uses d3-scale's `scaleBand` and `scaleLinear` to map country names and population values to screen coordinates, while `AxisBottom` and `AxisLeft` generate the tick marks and labels using D3's tick system. Bars are drawn as `rect` elements via the `Marks` component, with width proportional to each country's population. Data is fetched asynchronously using the `csv` function from D3 v6.

AI-generated description

Adding axes to the chart.

MIT Licensed

Similar vizzes