jlin
jlin

Reputation: 1

d3 choropleth map having problems with filling colors

I followed Mike Bostock choropleth example trying to make a world population choropleth map but I'm having trouble filling in colors correctly.

Here's my code and my data: http://bl.ocks.org/jeremycflin/572ca92be1dfe68ac0d3

Really, any answers or help that can take me to the right direction will be much appreciated.

Thank you in advance!

Upvotes: 0

Views: 153

Answers (1)

ekuusela
ekuusela

Reputation: 5282

Maybe try a different scale? China has quite a lot of people, pushing most of the countries to lower segments.

Everyone starting from place 4 will be at the lowest segment.

quantize(1330141295) // China
>"q8-9"

quantize(1173108018) // India
>"q7-9"

quantize(310232863) // United States
>"q2-9"

quantize(242968342) // Indonesia
>"q1-9"

quantize(201103330) // brazil
>"q1-9"

If you replace your maximum from the scale with for example the population of brazil you'll see that there will be more colors used.

var quantize = d3.scale.quantize()
        .domain([0,201103330])
        .range(d3.range(9).map(function(i) { return "q" + i + "-9"; }));

You could also use the quantile scale to utilize all segments.

Upvotes: 1

Related Questions