D3图例由于legendColor而未出现

时间:2016-10-25 17:50:25

标签: javascript d3.js

我的热图不会显示我的图例。它说错误:“d3.legendColor不是一个函数”,但我不确定如何将其更改为工作。

完整图表和完整代码:http://codepen.io/jeffm64/pen/gwQAyb

代码

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

1 个答案:

答案 0 :(得分:1)

如果您正在使用Susie Lu的 d3图例http://d3-legend.susielu.com/),则必须参考它:

A