<circle> преобразование атрибута: ожидаемое число, "translate (NaN, NaN)" в легенде D3 легенды трекера данных Covid - PullRequest
0 голосов
/ 26 мая 2020

Я получаю следующую ошибку при попытке добавить легенду к пузырьковой карте в d3.

<circle> attribute transform: Expected number, "translate(NaN,NaN)" 

Код, вызывающий ошибку:

if (that.type == 'Bubble') {
  legend
    .append("circle")
    .style("fill","none")
    .attr("cx", function (d, i) {
      return (
        that.legendContainerSettings.x + that.legendBoxSettings.width * i + 20
      );
    })
    .attr("cy", that.legendBoxSettings.y)
    .attr("r", function (d, i) {
      switch (that.scale) {
        case "Linear":
          return that.linearScale(that.linearScale.invert(d));
        case "Exponential":
          return that.expScale(that.expScale.invert(d));
        case "Logarithmic":
          return that.logScale(that.logScale.invert(d));
        case "Sqrrt":
          return that.sqrtScale(that.sqrtScale.invert(d));
      }
    })
    .style("opacity", 1)
    .style("fill", "black");
}

Демо проблемы можно найти по адресу:

https://jcbowyer.github.io/d3-in-angular/unitedstates/Filled/Sqrrt

Полный исходный код карты доступен по адресу:

https://github.com/jcbowyer/d3-in-angular/blob/master/src/app/unitedstates-map/unitedstates-map.component.ts

Что я могу сделать, чтобы решить эту проблему?

1 Ответ

0 голосов
/ 26 мая 2020

Проблема заключалась в другом блоке кода, где для параметра translate задавалось значение undefined.

...