d3-voronoi-treemap usage
This block demonstrates the d3-voronoi-map plugin by recreating HowMuch.net’s “The Costs of Being Fat, in Actual Dollars.” It partitions two circular polygons—one for men, one for women—into Voronoï treemap cells, where each cell’s area encodes the annual cost of a specific obesity-related expense (e.g., direct medical costs, sick leave). The data is loaded from a CSV file with two parallel weight columns (menCost and womenCost), and the plugin is used twice to generate separate Voronoï maps for each gender. The size of each circular treemap is scaled relative to the total cost for each gender, and cells are colored according to category. The visualization includes a legend and hover interaction for comparing the two maps, and is rendered in SVG using D3 v4.
AI-generated descriptionThis block illustrates the use of the d3-voronoi-map plugin. This block is a remake of the HowMuch.net's post The Costs of Being Fat, in Actual Dollars.
The d3-voronoi-map plugin produces Voronoï maps (one-level treemap). Given a convex polygon (here, a 60-gon simulating a circle for each gender) and weighted data, it tesselates/partitions the polygon in several inner cells, such that the area of a cell represents the weight of the underlying datum.
An iteration on this block enhances the user experience by (i) always producing the same Voronoï map on reloads and (ii) having the same layout (e.g. placing sites/cells of the same type at the same position) which eases comparison.
Acknowledgments to :
- D3.js (v.4)
- d3-voronoi-map plugin
- blockbuilder.org
- (part of) https://github.com/ArlindNocaj/Voronoi-Treemap-Library for a Java implementation
forked from <a href='http://bl.ocks.org/Kcnarf/'>Kcnarf</a>'s block: <a href='http://bl.ocks.org/Kcnarf/238fa136f763f5ad908271a170ef60e2'>d3-voronoi-map usage</a>