答案 0 :(得分:1)
我认为你正在寻找像这样的plot.ly colorscale:
https://plot.ly/javascript/heatmap-and-contour-colorscales/#hot-colorscale
如果这对您不起作用,并且您需要更多控制,则可以直接使用d3.js色标
http://synthesis.sbecker.net/articles/2012/07/16/learning-d3-part-6-scales-colors
var color = d3.scale.linear()
.domain([-1, 0, 1])
.range(["red", "white", "green"]);
color(-1) // "#ff0000" red
color(-0.5) // "#ff8080" pinkish
color(0) // "#ffffff" white
color(0.5) // "#80c080" getting greener
color(0.7) // "#4da64d" almost there..
color(1) // "#008000" totally green!