Skip to main content
100%

EXPLORING BAR CHART v2

✓ Published1🌍 Public
GGuillamon
Last edited Nov 18, 2019
Created on Oct 30, 2019

A sorted horizontal bar chart compares population counts for ten countries from a CSV file. Bars render in SVG with a green fill, and hovering highlights a bar while a tooltip div shows the country name and population. A click toggles bar color between green and magenta, and the chart calculates and displays a sum of all selected populations in a separate box. The visualization uses d3.scaleBand for the y-axis, d3.scaleLinear for the x-axis, and d3.axisBottom with dashed gridlines. Tooltip and selection logic rely on D3’s `.on('mouseover')`, `.on('mouseout')`, and `.on('click')` event handlers, with transitions animating the color changes.

AI-generated description

Mouseover and mouseout behaviour code taken from this tutorial: https://medium.com/@kj_schmidt/show-data-on-mouse-over-with-d3-js-3bf598ff8fc2

MIT Licensed

Similar vizzes