D3: Create a continuous color scale with many strings/inputs for the range and dynamically changing values of the domain

后端 未结 3 779
心在旅途
心在旅途 2021-01-31 10:19

I am trying to create a linear color scale for a heatmap. I want to color scale to go through a large set of specific colors, where the first color corresponds to the min of the

3条回答
  •  鱼传尺愫
    2021-01-31 11:12

    Use threshold scales. Here is a quick example:

    coffee> d3 = require 'd3'
    coffee> color = d3.scale.threshold().domain([5,30,100]).range(["red","orange","green"]);
    coffee> color 6
    'orange'
    coffee> color 3
    'red'
    coffee> color 33
    'green'
    

提交回复
热议问题