2016-08-19 80 views
-2

我是D3.js的新手,我試圖實現散點圖,我的圖表也在渲染,但我在控制檯。錯誤:<path>屬性的值無效d =「[object Object] D3.js

Error: Invalid value for attribute d="[object Object] D3.js

我的數據集是局部變量這是一個JSON對象。

請,檢查筆

http://codepen.io/7deepakpatil/pen/LkaKoy?editors=1000

的控制檯

請幫忙或提供一些線索。

+0

誤差從svg.append( 「路徑」)來ATTR( 「類」 ,「line」)。attr(「d」,data)。你在捆綁散點圖中使用什麼路徑? –

+1

@ChiragKothari,連接的散點圖在dataviz中很常見。爲此,我們使用路徑來連接圈子:http://steveharoz.com/research/connected_scatterplot/ –

回答

0

這是因爲您沒有線條生成器。補充一點:

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 

這是你的codepen:http://codepen.io/anon/pen/BzEQZR?editors=1000

相關問題