d3v3
schemeCategory20[bc]
在v4中不可用(??)和v5。
使用v3源代码中的颜色编号,并将它们转换为十六进制等效值,如果在v5中使用类似的话
var colors = d3.scaleOrdinal(d3.schemeCategory20b);
小片段
function d3_rgbHexString(value) { return "#" + (0x1000000 + value).toString(16).substring(1); }
d3.schemeCategory20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbHexString);
d3.schemeCategory20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbHexString);
d3.schemeCategory20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbHexString);