0
我想使用D3 parcoords創建一個使用CSV數據的平行座標圖,但似乎在線工作的所有示例在我的筆記本電腦本地無法正常工作(通過Chrome和Safari嘗試)。帶有CSV數據的D3
這是腳本加載CSV數據:
d3.csv('datatest.csv', function(data) {
pcz = d3.parcoords()("#example-zscore")
.data(data)
//.hideAxis(["name"])
.composite("darker")
.render()
.alpha(0.35)
.brushMode("1D-axes") // enable brushing
.interactive() // command line mode
change_color("weight (lb)");
// click label to activate coloring
pcz.svg.selectAll(".dimension")
.on("click", change_color)
.selectAll(".label")
.style("font-size", "14px");
});
需要注意的是,如果我改變.data(data)
到:
.data([
[0,-0,0,0,0,1],
[1,-1,1,2,1,1],
[2,-2,4,4,0.5,1],
[3,-3,9,6,0.33,1],
[4,-4,16,8,0.25,1]
])
然後用這個數據的圖形繪製。
我的CSV樣子:
name,economy (mpg),cylinders,displacement (cc),power (hp),weight (lb),0-60 mph (s),year
AMC Ambassador Brougham,13,8,360,175,3821,11,73
AMC Ambassador DPL,15,8,390,190,3850,8.5,70
AMC Ambassador SST,17,8,304,150,3672,11.5,72
AMC Concord DL 6,20.2,6,232,90,3265,18.2,79
AMC Concord DL,18.1,6,258,120,3410,15.1,78