d3.js : d3.min.js:1 Error: attribute d: Expected number, “MNaN,NaNLNaN,NaN”

后端 未结 2 1681
清歌不尽
清歌不尽 2020-12-31 01:11

I imported a csv file and tried to map the info on d3. I guess I have scaled everything properly. Can anyone help me out and guide me through this?

I get the followi

2条回答
  •  [愿得一人]
    2020-12-31 01:40

    x.range([0, width]);
    y.range([height, 0]);
    

    Should before

    line = d3.svg.line()
        .x(function(d) { return x(new Date(d.date)) })
        .y(function(d) { return y(d.value) });
    

    Like this

      x = d3.time.scale().domain(xExtent).range([0, width]);
      y = d3.scale.linear().domain(yExtent).range([height, 0]);
    line = d3.svg.line()
        .x(function(d) { return x(new Date(d.date)) })
        .y(function(d) { return y(d.value) });
    

提交回复
热议问题