我正在用https://bl.ocks.org/d3noob/5028304中的示例製作一個d3 Sankey圖。此示例適用於較小的數據集。當我切換到使用更大的數據集時,可視化中斷。看起來問題是dy值變爲負值。大數據集中斷d3 sankey圖
在控制檯中,錯誤的是:
Error: <rect> attribute height: A negative value is not valid. ("-9.02557856272838")
代碼它指向的是:
node.append("rect")
.attr("height", function(d) { return d.dy; })
這也許是因爲該地塊要關閉屏幕?我看着使用D3尺度,但我不知道如何實現它們。也許是這樣的:
d3.scale.ordinal()
.domain(data.map(function(d) { return d.name; }))
.rangeRoundBands([0, height], .2);
或者,也許有一種方法來縮小可視化數據集變得越來越大,這樣一切都會適合於容器中。
這裏是我的代碼:https://plnkr.co/edit/hOjEBHhS7vfajD2wb8t9?p=preview