D3 中的 colorbrewer 子集
Subset of colorbrewer set in D3
我只想使用 colorbrewer.js 的 'Blues' 颜色集中的 5 种最深的颜色。我怎么做?我找不到任何涉及它的文档。这是我的代码:
var colorScale = d3.scale.quantize()
.domain([0, maxInteractions*2])
.range(colorbrewer.Blues[9]);
colorbrewer.Blues[9]
只是一组颜色。您可以使用旧 array.slice()
来获取最后五个元素。
colorbrewer.Blues[9]
//["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"]
colorbrewer.Blues[9].slice(4)
//["#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"]
我只想使用 colorbrewer.js 的 'Blues' 颜色集中的 5 种最深的颜色。我怎么做?我找不到任何涉及它的文档。这是我的代码:
var colorScale = d3.scale.quantize()
.domain([0, maxInteractions*2])
.range(colorbrewer.Blues[9]);
colorbrewer.Blues[9]
只是一组颜色。您可以使用旧 array.slice()
来获取最后五个元素。
colorbrewer.Blues[9]
//["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"]
colorbrewer.Blues[9].slice(4)
//["#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"]