1

I am trying to modify the code from this example (https://d3-geomap.github.io/map/choropleth/custom-domain/) so that it can handle a larger range of data than just 1/0 values.

Basically, I have a CSV file in which I have attached values from 1 to 13 to different countries according to a custom grouping I have defined, and I want to be able to choose a specific colour for each number. I tried changing the data domain to be [1, 13] or [1, 2,..., 13] and setting the colours accordingly, but neither of these methods worked. I'm not sure I fully understand the domain property, and want to know whether or not it's possible (and if so, how) to do my custom colouring.

Here are the two things I tried:

var map = d3.geomap.choropleth()
.colors(['green','red'])
.domain([1, 13])
....

var map = d3.geomap.choropleth()
.geofile('countries.json')
.colors(['green','red', 'blue', 'orange', 'yellow', 'purple', 'violet', 'black', 'brown', 'green', 'red', 'blue', 'orange'])
.domain([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
Sibonay
  • 11
  • 1

0 Answers0