in this iteration, we use the ckmeans algorithm from the simple-statistics package to cluster our data. we pick the minimum value of each cluster as a break. we then use these breaks with a quantile scale to map values in the data to colors on the choropleth map.
this is method is my current favorite way to create breaks, or color thresholds, for a choropleth map.
🎩 @Elijah_Meeks for the idea to try the ckmeans algorithm, as it seems to be the new hotness in the choropleth map breaks scene
a further 🙏 to @recifs for talking through where in the ckmeans clusters its reasonable to pick breaks from.
tl;dr any number between max(class n) and min(class n+1) is OK
do check out the other examples in this world map
series:
world map 00 original example
world map 01 fix tooltip value
world map 02 d3 v4
world map 03 es2015 + update code style
world map 04 manual breaks + threshold scale
world map 05 linear breaks + quantize scale
world map 06 linear breaks + quantiles scale
world map 07 Jenks natural breaks
world map 08 ckmeans cluster max breaks
world map 09 ckmeans cluster min breaks
https://d3js.org/d3.v4.min.js
https://d3js.org/queue.v1.min.js
https://d3js.org/topojson.v1.min.js
https://d3js.org/d3-geo-projection.v1.min.js
https://unpkg.com/simple-statistics@2.0.0/dist/simple-statistics.min.js
https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.10.3/babel.min.js