|
|
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>JS Bin</title>
- <script type="text/javascript" src="../dist/vis.js"></script>
- <link href="../dist/vis.css" rel="stylesheet" type="text/css" />
- <style>
- #mynetwork {
- width: 700px;
- height: 450px;
- border: 1px solid lightgray;
- }
- </style>
-
- <script>
- var network = null;
- function destroy() {
- if (network !== null) {
- network.destroy();
- network = null;
- }
- }
-
- function draw() {
- destroy();
- var container = document.getElementById('mynetwork');
- var nodes = new vis.DataSet();
- var edges = new vis.DataSet();
- nodes.add({id:1})
- data = {
- nodes: nodes,
- edges:edges
- }
-
- options = {
- edges: {
- arrows:{
- to: true
- },
- smooth:{
- enabled: true
- }
- },
- interaction:{
- navigationButtons:true
- },
- physics:{
- enabled: true,
- stabilization: true
- },
- manipulation:{
- enabled: false,
- addEdge: function (data, callback) {
- setTimeout(function () {network.addEdgeMode();},0);
- callback(data);
- }
- }
- };
-
- network = new vis.Network(container, data, options);
- network.addEdgeMode();
-
- }
- </script>
- </head>
- <body onLoad="draw()">
- <button id="addNodeLayer1">Layer 1</button>
- <button id="addNodeLayer2">Layer 2</button>
- <button id="addNodeLayer3">Layer 3</button>
- <div id="mynetwork"></div>
- </body>
- </html>
|