UNPKG

1.51 kBHTMLView Raw
1<!doctype html>
2<html>
3<head>
4 <title>Network | Label alignment</title>
5
6 <script type="text/javascript" src="../../../dist/vis-network.min.js"></script>
7 <link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" />
8
9 <style type="text/css">
10 #mynetwork {
11 width: 600px;
12 height: 600px;
13 border: 1px solid lightgray;
14 }
15 p {
16 max-width:600px;
17 }
18 </style>
19
20</head>
21
22<body>
23
24<p>Labels can have any color background.</p>
25
26<div id="mynetwork"></div>
27
28<script type="text/javascript">
29 // create an array with nodes
30 var nodes = [
31 {id: 1, label: 'Node 1', font: {background: 'red'}},
32 {id: 2, label: 'Node 2', font: {background: 'white'}},
33 {id: 3, label: 'Node 3', font: {background: 'cyan'}},
34 {id: 4, label: 'Node 4', font: {background: 'lime'}},
35 {id: 5, label: 'Node 5', font: {background: 'pink'}}
36 ];
37
38 // create an array with edges
39 var edges = [
40 {from: 1, to: 2, label: 'label1', font: {background: '#ff0000'}},
41 {from: 1, to: 3, label: 'label2', font: {background: 'yellow'}},
42 {from: 2, to: 4, label: 'label3', font: {background: 'lime'}},
43 {from: 2, to: 5, label: 'label3', font: {background: 'pink'}}
44 ];
45
46 // create a network
47 var container = document.getElementById('mynetwork');
48 var data = {
49 nodes: nodes,
50 edges: edges
51 };
52 var options = {nodes:{font:{strokeWidth:0}}, edges:{font:{strokeWidth:0}}};
53 var network = new vis.Network(container, data, options);
54</script>
55
56</body>
57</html>