如何使Highcharts Heatmap颜色不基于渐变/百分比,而基于颜色值范围

kuhbmx9i  于 2022-11-10  发布在  Highcharts
关注(0)|答案(1)|浏览(264)

我希望颜色像Gitlab的贡献热图一样(左下角是颜色范围):

// [value, color]
stops: [
    [0, '#ededed'],
    [1-9, '#acd5f2'],
    [10-19, '#7fa8c9'],
    [20-29, '#527ba0'],
    [30+, '#254e77']
]

有谁知道我怎么用Highcharts Heatmap做吗?

ipakzgxi

ipakzgxi1#

您需要为颜色轴使用数据类。例如:

colorAxis: {
    ...,
    dataClasses: [{
      color: '#ededed',
      to: 1
    }, {
      color: '#acd5f2',
      from: 1,
      to: 9
    }, {
      color: '#7fa8c9',
      from: 10,
      to: 19
    }, {
      color: '#527ba0',
      from: 20,
      to: 29
    }, {
      color: '#254e77',
      from: 30
    }]
  }

现场演示:https://jsfiddle.net/BlackLabel/9qd1Lewp/
API引用:https://api.highcharts.com/highcharts/colorAxis.dataClasses

相关问题