Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse color mapping in d3

I have a set of numbers from 1 to 100 -- they're rankings, so 1 is greater than 2 (30 is greater than 100, etc.)

This is my color function right now:

var color = d3.scale.linear()
            .domain([0, 100])
            .range(colorbrewer.Reds[3]);

Except this maps 1's and 2's as the lighter shades or Red.

Any ideas how to go about this? I think my terminology (reverse? inverse color mapping?) is incorrect because I can't find this in the documentation.

Thank you.

like image 759
fhbi Avatar asked Mar 12 '26 02:03

fhbi


1 Answers

D'oh.

Reverse the domain .....

var color = d3.scale.linear()
            .domain([100, 0])
            .range(colorbrewer.Reds[3]);

YOLO

like image 99
fhbi Avatar answered Mar 13 '26 15:03

fhbi