Javascript 错误:无效的<;值;路径>;属性d=";[object]D3.js

Javascript 错误:无效的<;值;路径>;属性d=";[object]D3.js,javascript,json,d3.js,Javascript,Json,D3.js,我是D3.js新手,正在尝试实现散点图,我的图表也在渲染,但我在控制台中遇到以下错误 错误:属性d=“[object]D3.js”的值无效 我的数据集是局部变量,它是一个json对象 请检查一下钢笔的控制台 请提供帮助或线索。这是因为您没有线路生成器。请添加以下内容: var line = d3.svg.line() .interpolate("monotone")//change this if you want .x(function(d) { return

我是D3.js新手,正在尝试实现散点图,我的图表也在渲染,但我在控制台中遇到以下错误

错误:属性d=“[object]D3.js”的值无效

我的数据集是局部变量,它是一个json对象

请检查一下钢笔的控制台


请提供帮助或线索。

这是因为您没有线路生成器。请添加以下内容:

var line = d3.svg.line()
    .interpolate("monotone")//change this if you want
    .x(function(d) {
        return x(d.date);
    })
    .y(function(d) {
        return y(d.IPname);
});
然后附加路径:

svg.append("path")
   .attr("class", "line")
   .attr("d", line(data))
   .attr("fill", "none")
   .attr("stroke", "gray");//change the color here

这是您的代码笔:

错误来自svg.append(“path”).attr(“class”,“line”).attr(“d”,data)。您在散点图中使用path做什么?@ChiragKothari,连接散点图在dataviz中非常常见。为此,我们使用一条路径连接圆:
svg.append("path")
   .attr("class", "line")
   .attr("d", line(data))
   .attr("fill", "none")
   .attr("stroke", "gray");//change the color here