admin管理员组

文章数量:1296257

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.

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.

Share Improve this question asked Mar 25, 2015 at 21:51 fhbifhbi 7527 silver badges17 bronze badges 1
  • 1 have you tried simply reversing the domain values? EDIT: just saw your answer, glad you figured it out yourself :) – tomtomtom Commented Mar 25, 2015 at 21:55
Add a ment  | 

1 Answer 1

Reset to default 12

D'oh.

Reverse the domain .....

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

YOLO

本文标签: javascriptReverse color mapping in d3Stack Overflow