2017-05-21 15 views
-1

我是D3的新手,我開始將示例氣泡圖從v3轉換爲v4。我得到bubble.nodes is not a function類似於this question在D3中將氣泡圖從V3轉換爲V4

但是,我不知道如何應用過濾器。我已將我的代碼放入plunker。有人可以幫忙嗎?

在此先感謝。

+0

'bubble(節點)'與'bubble.nodes'有很大的不同。 –

回答

0

佈局功能d3更改substantially between versions 3 and 4。其要點是,您現在需要在將數據傳遞到佈局之前調用d3.hiearchypreprocess。返工你的代碼看起來是這樣的:

d3.json("flare.json", function(json) { 

    var root = d3.hierarchy(classes(json)) 
    .sum(function(d) { return d.value; }); 

    var node = vis.selectAll("g.node") 
    .data(bubble(root).leaves()) 
    .enter().append("svg:g") 
    ... 

更新plunker here

+0

非常感謝您的幫助 – Selva