score:1

Accepted answer

The country's color will depend on a value. So the color IS a function of "value". To do that you must to define a range of color based on your values:

var color = d3.scale.linear()
                      .domain([mn,mx])      // <--- min and MAX of your value
                      .range(["#ffffff","000000"]);

then define the color of your country:

svg.selectAll(".county")
                  .style("fill", function(array_values) {
                        return color(array_values[d.country]);
                  });

Must-Read: Jerome Cukier - d3: scales, and color


Related Query

More Query from same tag