2015-05-04 130 views
0

我試圖繪製堆積面積圖d3堆積面積圖中未繪製的路徑

我將問題解決到this plunker

示例數據在下面,我確認數據(由堆棧佈局重新計算)傳遞給區域生成器函數areaFcn。只是路徑永遠不會被數據更新。我不知道爲什麼。

有人嗎?

謝謝!

var areaFcn = function(d, i) { 
d3.svg.area() 
.x(function(d, i) { return xScaleT(d.t); }) 
.y0(function(d) { return yScale(d.y0); }) 
.y1(function(d) { return yScale(d.y0 + d.y); }); 
} 

var inData = [ {"data":[ 
{"svName":"BBC [890]","avgBW":9654498}, 
{"svName":"CNN [453]","avgBW":4033202}, 
{"svName":"ESPN [984]","avgBW":4715123}], 
"timestamp":1430712151000}, 
{"data":[ 
{"svName":"BBC [890]","avgBW":9654498}, 
{"svName":"CNN [453]","avgBW":4033202}, 
{"svName":"ESPN [984]","avgBW":4715123}], 
"timestamp":1430712153000}, 
{"data":[ 
{"svName":"BBC [890]","avgBW":4103549}, 
{"svName":"CNN [453]","avgBW":4413707}, 
{"svName":"ESPN [984]","avgBW":11648783}], 
"timestamp":1430712156000} 
] 

http://plnkr.co/edit/dVU7NRwVsxjiQLRRKnoS

回答

1

的路徑沒有d屬性。代碼中的一些調試顯示,函數areaFcn返回未定義。改變它並且它將工作:

var areaFcn = d3.svg.area() 
.x(function(d, i) { 
    return xScaleT(d.t); }) 
.y0(function(d) { 
    return yScale(d.y0); }) 
.y1(function(d) { 
    return yScale(d.y0 + d.y); });