1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | <html> <head> <!-- jquery cdn --> integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script> <!-- vis js --> <script type="text/javascript" src="vis.min.js"></script> <link type="text/css" href="vis.min.css" rel="stylesheet" media="screen"> </head> <body> <!-- the graph will be rendered here --> <div id="div_vis_graph" width="100%" height="100%"></div> <script type="text/javascript"> $(document).ready( function() { // graph container var container = document.getElementById("div_vis_graph"); // raw data for nodes var data_nodes = [ {id: 1, label: 'Num 1', title: 'N1 Title'}, {id: 2, label: 'Num 2', title: 'N2 Title'}, {id: 3, label: 'Num 3', title: 'N3 Title'}, {id: 4, label: 'Num 4', title: 'N4 Title'}, {id: 5, label: 'Num 5', title: 'N5 Title'}, {id: 6, label: 'Num 6', title: 'N6 Title'}, {id: 7, label: 'Num 7', title: 'N7 Title'} ]; // raw data for edges var data_edges = [ {from: 1, to: 2, arrows: 'to'}, {from: 1, to: 3, arrows: 'to, from'}, {from: 1, to: 4, arrows: 'to'}, {from: 2, to: 3, arrows: 'to'}, {from: 2, to: 4, arrows: 'to'}, {from: 3, to: 5, arrows: 'to from'}, {from: 5, to: 6, arrows: 'to'}, {from: 5, to: 7, arrows: 'to'} ]; // translate raw data to vis format var nodes = new vis.DataSet(data_nodes); var edges = new vis.DataSet(data_edges); // setup whole data (node and edge) var data = { nodes : nodes, edges : edges }; // other options var opt = { layout : { improvedLayout: false }, height: "100%", width : "100%" }; // render it ! var network = new vis.Network(container, data, opt); }); </script> </body> </html> | cs |