2016-04-15 149 views
0

我試圖用d3實現Sankey插件。我沒有得到我期望的輸出。希望有人能幫助。 我已經簡化爲最簡單的數據集。 有3個節點。我期望一個鏈接從進入到退出,一個從進入到Zone1,然後是退出。這裏是集:Sankey數據格式化,演示文稿

const graph = { 
nodes: [ 
    {'node': 0, 'name': 'Entry'}, 
    {'node': 1, 'name': 'Zone 1'}, 
    {'node': 2, 'name': 'Exit'} 
], 
links: [ 
    {"source": 0, "target": 1, "value": 2}, 
    {"source": 1, "target": 2, "value": 2}, 
    {"source": 0, "target": 2, "value": 4} 
] 
} 

不過我剛開始一個鏈路路徑,並且還看起來有點混搭 enter image description here 這裏是鏈接代碼:

var link = svg.append("g").selectAll(".link") 
     .data(graph.links) 
     .enter().append("path") 
     .attr("class", "link") 
     .attr("d", path) 
     .style("stroke-width", function (d) { 
      return Math.max(1, d.dy); 
     }) 
     .sort(function (a, b) { 
      return b.dy - a.dy; 
     }); 
    link.append("title") 
     .text(function (d) { 
      return d.source.name + " → " + 
       d.target.name + "\n" + format(d.value); 
     }); 

回答

0

也沒有明確的筆畫顏色在鏈接代碼中。我只需要補充:

.attr("stroke", "#CDCDCD")