我正在使用d3.js构建一个饼图,并可视化一个大数据集.图表上可以显示超过137个项目.我只有10种颜色使用此功能.
d3.scale.category10().range()
Run Code Online (Sandbox Code Playgroud)
通过探索其他选项:https: //github.com/mbostock/d3/wiki/Ordinal-Scales
d3.scale.category20().range()
var chart = nv.models.pieChart()
.x(function(d) {
return d.key
})
.y(function(d) {
return d.y
})
.color(d3.scale.category10().range())
.width(width)
.height(height);
Run Code Online (Sandbox Code Playgroud)
如何使用d3生成尽可能多的颜色?