Ошибка при использовании функции legendColor с d3.scaleSequential.interpolator - PullRequest
0 голосов
/ 05 марта 2020

Я пытаюсь создать тепловую карту вместе с легендой. Для тепловой карты я использую данные из файла json, и у меня есть следующий код:

`   const MaxAvgPrice = d3.max(lines,  (d) => d.properties.avgprice)

    // uses a color scale for the map and fill the map
    const colorScale = d3.scaleSequential().domain([0,MaxAvgPrice])
    .interpolator(d3.interpolateOranges);

    neighbourhoodPath.attr('fill', (d) => colorScale(d.properties.avgprice))


    // creates the legend
    console.log("The domain is: " + colorScale.range);


    const legendScale = d3.legendColor()
        .scale(colorScale)
        .shapePadding(1)
        .shapeWidth(30)
        .shapeHeight(70)
        .labelOffset(5)
        .ascending(false)
        .useClass(true)
        .cells(5);



    const legend = svg.append('g')
        .attr('class', 'legend')
        .attr("transform", "translate(5, 30)")
        .call(legendScale)

И функция legendColor сообщает мне:

legend. js: 102 Uncaught (в обещании) TypeError: scale.range не является функцией

Есть идеи, почему я это получаю?

спасибо!

...