Colors via map
You can color features by passing:
• `keyToColor`, a object mapping region `key|key_alt` to color (see below);
• `key`, the key to be used in the features `properties` field as the region identifier, e.g. `iso_a2`;
• Note that you might provide a topojson where not all the objects have the provided `key`.
For example if you provide `key: 'iso_a2'` (ISO Alpha 2 codes), disputed or partially recognised countries might not have that code (e.g. `Kosovo`).
For these cases you can provide a `key_alt`, equal to `name` by default.
Note that if you pass both `keyToColor` and `keyToColorFn`, `keyToColor` takes precedence.
Also note that if the value returned by `keyToColor` is falsy the fallback is `defaultFill` (which defaults to `white`).
Choose an example
Usage
<ChoroplethG {height} {width} key='iso_a2' keyToColor={keyToColorWorld} topojson={world_110m_iso_a2} topojsonId='countries' />
Props
key
- "iso_a2"
keyToColor
- { AM: "blue" ,AT: "blueviolet" ,AZ: "chartreuse" ,BY: "rgb(255, 69, 0)" ,BE: "brown" , … }
- AM: "blue"
- AT: "blueviolet"
- AZ: "chartreuse"
- BY: "rgb(255, 69, 0)"
- BE: "brown"
- BA: "aquamarine"
- BG: "rgb(128, 128, 0)"
- HR: "cadetblue"
- CY: "deepskyblue"
- CZ: "gold"
- DK: "chocolate"
- EE: "cornflowerblue"
- FI: "dimgray"
- FR: "firebrick"
- GE: "rgb( 65, 105, 225)"
- DE: "greenyellow"
- GR: "darkgoldenrod"
- HU: "darkmagenta"
- IS: "dodgerblue"
- IE: "crimson"
- IT: "darkcyan"
- KZ: "darkblue"
- LV: "darkturquoise"
- LI: "coral"
- LT: "darkkhaki"
- LU: "lightsalmon"
- MT: "darkorchid"
- MD: "darkolivegreen"
- MC: "darkslategray"
- ME: "darkslateblue"
- NL: "rgb(216, 191, 216)"
- MK: "tomato"
- NO: "darksalmon"
- PL: "rgb(238, 130, 238)"
- PT: "darkred"
- RO: "red"
- RU: "green"
- SM: "rgb(188, 143, 143)"
- RS: "darkorange"
- SK: "rgb( 0, 0, 128)"
- SI: "darkseagreen"
- ES: "lightblue"
- SE: "mediumseagreen"
- CH: "rgb(255, 255, 0)"
- TR: "yellowgreen"
- UA: "rgb(152, 251, 152)"
- GB: "rgb(128, 0, 128)"
topojson
- { type: "Topology" ,objects: {…} ,arcs: Array(595) ,bbox: Array(4) ,transform: {…} }
- type: "Topology"
- objects: { countries: {…} ,land: {…} }
- arcs: (595) [ Array(9) ,Array(11) ,Array(5) ,Array(11) ,Array(9) , … ]
- bbox: (4) [ -180 ,-85.60903777459771 ,180 ,83.64513000000001 ]
- transform: { scale: Array(2) ,translate: Array(2) }
topojsonId
- "countries"