J64
J64

Reputation: 84

D3 legend not appearing due to legendColor

My legend won't appear for my heatmap. It says the error: "d3.legendColor is not a function" but I am unsure of how to change it to work.

full chart and full code: http://codepen.io/jeffm64/pen/gwQAyb

The code

var colorScale = d3.scaleQuantile()
                       .domain([minVariance + baseTemp, maxVariance + baseTemp])
                       .range(colors);

//creates the legend for the heatmap
    d3.select("svg")
      .append("g")
      .attr("class", "legendQuant")
      .attr("transform", "translate(20,20)");

    var legend = d3.legendColor()
      .labelFormat(d3.format(".2f"))
      .useClass(true)
      .scale(colorScale);

    svg.select(".legendQuant")
      .call(legend);

Upvotes: 4

Views: 5783

Answers (1)

Gerardo Furtado
Gerardo Furtado

Reputation: 102174

If you are using Susie Lu's d3 Legend (http://d3-legend.susielu.com/), you'll have to reference it:

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-legend/2.13.0/d3-legend.js"></script>

Upvotes: 2

Related Questions