TopoView.html是一个已经写好的实例,直接在浏览器打开即可
<div id="topoView">
<svg>
</svg>
</div>
<script src="./d3.min.js"></script>
<script src="./topoView.js"></script>
var snodes = [{
"id": "1"
}, {
"id": "2"
}, {
"id": "3"
}];
var hnodes = [{
"id": "5"
}, {
"id": "6"
}];
var links = [{
"source": "1",
"target": "2"
}, {
"source": "2",
"target": "3"
}, {
"source": "5",
"target": "1"
}, {
"source": "6",
"target": "3"
}]
var topoView = new TopoView("topoView");
topoView.setTopoInfo(snodes, hnodes, links);
topoView.updateTopoView();