如何改变d3plus环中箭头的方向

时间:2016-08-30 04:55:59

标签: javascript d3plus

如何将target的{​​{1}}改为sourcesource更改为target按照Object .edges( Array | Object | url )所述的文档进行更改1}}方法。 D3plus Documentation。 完整的代码如下,以了解箭头方向。

<!doctype html>
<meta charset="utf-8">
<script src="//d3plus.org/js/d3.js"></script>
<script src="//d3plus.org/js/d3plus.js"></script>
<div id="viz"></div>
<script>
  var connections = [
{"source": "alpha", "target": "beta"},
{"source": "alpha", "target": "gamma"},
{"source": "alpha", "target": "delta"},
{"source": "alpha", "target": "epsilon"},
{"source": "alpha", "target": "peta"},
{"source": "alpha", "target": "zeta"},
{"source": "alpha", "target": "eta"}
  ]
var visualization = d3plus.viz()
    .container("#viz")  
    .type("rings")      
    .edges(connections) 
    .edges({"direction":{"accepted":["source","target"],"value":"source"}})
    //.adeges({"direction":{"accepted":["source","target"],"value":"target"}})
    .edges({"arrows":true,"color":"#000000"})
    .focus("alpha")     
    .draw()
</script>

控制台消息。 Console Message

1 个答案:

答案 0 :(得分:2)

试试这个:

<!doctype html>
<meta charset="utf-8">
<script src="//d3plus.org/js/d3.js"></script>
<script src="//d3plus.org/js/d3plus.js"></script>
<div id="viz"></div>
<script>
    var connections = [
        {"source": "alpha", "target": "beta"},
        {"source": "alpha", "target": "gamma"},
        {"source": "alpha", "target": "delta"},
        {"source": "alpha", "target": "epsilon"},
        {"source": "alpha", "target": "peta"},
        {"source": "alpha", "target": "zeta"},
        {"source": "alpha", "target": "eta"}
    ]
    var visualization = d3plus.viz()
    .container("#viz")  
    .type("rings")      
    .edges(connections) 
    .edges({"arrows":true, "color":"#000000"})
    .edges({"arrows": { "value": ["source","target"], "direction": "source"}})
    .focus("alpha")     
    .draw()
</script>