Skip to main content
100%

Sortable Table with Bars

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Sep 14, 2012

This example displays demographic data for U.S. states as a sortable HTML table, where each age-bracket column is rendered as a horizontal bar chart. Clicking a column header re-sorts the table rows by the proportion of the population in that age range, with bar lengths proportional to that share. The visualization uses D3 v3 to load the CSV data with `d3.csv`, then builds the table structure with `d3.select`, `selectAll`, and `.data`, appending SVG elements to each cell. The bars are drawn as `rect` elements whose widths are calculated from the percentage values, with hover styling applied via CSS.

AI-generated description
gpl-3.0 Licensed

Similar vizzes