daydreamer
daydreamer

Reputation: 92179

D3 colors are not coming up as expected

I am using this plunker as example

and I created this plunker with same color scales

Problem?

I don't really understand how the following function works

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); })

I am not sure how can I bring my pie charts to life by using colors

Upvotes: 0

Views: 68

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109282

If you want specific colours, it will be easier to simply assign them instead of using a scale. Instead of using a custom scale, you might also want to use the color scales D3 provides.

Upvotes: 1

Related Questions