2017-04-11 416 views
1

我有一個vis.js網絡圖,其中包含多個節點之間的邊,我也嘗試使用分層佈局來設置它。如果我做一個沒有分層佈局選項的正常圖形,那麼節點之間會顯示多條線,但是,一旦我打開/放置在分層佈局選項中,只繪製一條線。[visjs]中節點和分層佈局之間的多條線

下面是兩個plunkers顯示我的意思:

https://plnkr.co/edit/c8SuBc0XjDZnn6im2vdg(Plunker與分層佈局關閉)

var options = { 
    height: '400px', 
    edges: { smooth: true, shadow: true}, 
    layout: { 
     randomSeed: 1, 
     improvedLayout: true, 
     hierarchical: { 
      enabled: false, //change to true to see the other graph 
      direction: 'UD', 
      sortMethod: 'directed' 
     } 
    } 
} 

https://plnkr.co/edit/L22bHk6kh1XKXulTjESD(Plunker與分層佈局)

var options = { 
    height: '400px', 
    edges: { smooth: true, shadow: true}, 
    layout: { 
     randomSeed: 1, 
     improvedLayout: true, 
     hierarchical: { 
      enabled: true, //change to true to see the other graph 
      direction: 'UD', 
      sortMethod: 'directed' 
     } 
    } 
} 

任何幫助將很棒。

回答

1

我需要同樣的事情,所以我搜查,發現你的問題:)

好像沒有其他的方式來做到這一點,只能通過邊緣屬性,請參閱:https://plnkr.co/edit/ylg9eE3Zk5ReCyjehI6H

var edges = new vis.DataSet([ 
    {from: 1, to: 3, arrows: 'to', label: "+++++", smooth: {type: "curvedCCW", roundness: 0.4}}, 
    {from: 1, to: 3, arrows: 'to', label: "-----", smooth: {type: "curvedCCW", roundness: 0.2}}, 
    {from: 1, to: 3, arrows: 'to', label: "11111", smooth: {type: "curvedCW", roundness: 0.2}}, 
    {from: 1, to: 3, arrows: 'to', label: "22222", smooth: {type: "curvedCW", roundness: 0.4}}, 
]); 

請分享您的在這個問題上的發現

+0

是從A-> B有多個邊的目的? –

+0

@John是的,節點之間有多條邊。 –

+0

從我最近找到的庫中添加更多支持。 https://github.com/almende/vis/issues/2957和https://github.com/almende/vis/issues/1957。 –