0

我以这个 plunker为例

我用相同的色阶创建了这个 plunker

问题?

我真的不明白以下功能是如何工作的

var color = d3.scale.ordinal()
                .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);

g.append("path")
      .attr("d", arc)
      .style("fill", function(d) { 
        //console.log('d: ' + JSON.stringify(d, null, 4));
        return color(d.value); })

我不知道如何通过使用颜色使我的饼图栩栩如生

4

1 回答 1

1

如果你想要特定的颜色,简单地分配它们而不是使用比例会更容易。除了使用自定义比例,您可能还想使用D3 提供的颜色比例

于 2013-06-17T17:15:12.423 回答