National Official Languages in the Americas 2
A choropleth of the Americas colors each country according to its official languages, using a repeating stripe pattern generated by the d3.patternStripes helper. The map is rendered with SVG paths from GeoJSON, with each nation assigned a distinct stripe direction or color combination from the d3.autoStripes palette. Hovering over a country highlights its borders and reveals the specific official languages in a tooltip.
AI-generated descriptionThe map shows official languages (at a national level, sorry regional official languages) by country. Though, not all countries have official languages, so I've used a bit of discretion. Also, in the case of Bolivia, with a multitude of official languages, some of which may be extinct, I've shown some of the more major languages
The block adds a bit to the pattern module with the uncreatively named autoStripes function. This is a slight evolution from this bl.ock meant to automate the assignment of stripes and solids.
The patterner takes datums, one at at time, and determines if the current datum matches any previous datums. If so it returns:
- In the event of single value, the color returned by the prevoius matching datum.
- In the event of multiple values, the stripe pattern url returned by the prevoius matching datum.
If the datum does not match previous datums, then it returns:
- In the event of a single value, a new color
- In the event of multiple values, a new stripe pattern url.
Color usage is consistent - whether stripes or solids.
Also, patterns aren't duplicated, to reduce the potential for extra nodes in the DOM. However, there may be some merit in allowing duplication. For example, to allow for mouseover effects.
This is just an idea at the moment - I hope to have something a little more polished and complete soon.