Oxford_orange
Oxford_orange

Reputation: 157

Legend titles in D3

I am having trouble with the titles in my legend in the Blockbuilder below.

This snippet defines the scale used for the legend titles:

var color = d3.scale.ordinal()
    .domain(["Pass", "Fail", "No Data"])
    .range(["green", "red", "black"]);

However, I can't get them to display correctly.

Here is the link to the Blockbuilder.

Upvotes: 1

Views: 581

Answers (1)

Gerardo Furtado
Gerardo Furtado

Reputation: 102174

Instead of passing the scale's range, pass its domain:

var legend = svg.selectAll('.legend')                     
    .data(color.domain())  
    .enter()                                                
    .append('g');

Here is the updated blockbuilder: http://blockbuilder.org/anonymous/4779ee79f034c443ac0119cf26bc5392

Upvotes: 1

Related Questions