Vis Network 图表生成:10个节点的图示例
<!DOCTYPE html>
<html>
<head>
<title>Vis Network Example</title>
<script type="text/javascript" src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script>
<style type="text/css">
#network {
width: 600px;
height: 400px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<div id="network"></div>
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet([
{ id: 1, label: 'Node 1' },
{ id: 2, label: 'Node 2' },
{ id: 3, label: 'Node 3' },
{ id: 4, label: 'Node 4' },
{ id: 5, label: 'Node 5' },
{ id: 6, label: 'Node 6' },
{ id: 7, label: 'Node 7' },
{ id: 8, label: 'Node 8' },
{ id: 9, label: 'Node 9' },
{ id: 10, label: 'Node 10' }
]);
<pre><code>// create an array with edges
var edges = new vis.DataSet([
{ from: 1, to: 2 },
{ from: 1, to: 3 },
{ from: 2, to: 4 },
{ from: 2, to: 5 },
{ from: 3, to: 6 },
{ from: 3, to: 7 },
{ from: 4, to: 8 },
{ from: 5, to: 9 },
{ from: 6, to: 10 }
]);
// create a network
var container = document.getElementById('network');
var data = {
nodes: nodes,
edges: edges
};
var options = {
layout: {
hierarchical: {
direction: 'UD'
}
}
};
var network = new vis.Network(container, data, options);
</code></pre>
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/mNNB 著作权归作者所有。请勿转载和采集!