HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function() {
2
3
// create data
4
var data= {
5
"nodes":[
6
{id:'Kate Austin', height: '30', fill: '#64b5f6'},
7
{id:'Reece Gray'},
8
{id:'Darren Burch'},
9
{id:'Leslie Bailey'},
10
{id:'Nova Fisher'},
11
12
{id:'Jack Austin', height: '30', fill: '#64b5f6'},
13
{id:'Jamie Montoya'},
14
{id:'Sawyer Mack'},
15
{id:'Hugo Love'},
16
17
{id:'Sophie Lilly', height: '30', fill: '#64b5f6'},
18
{id:'Ivy Mcintyre'},
19
{id:'Evie West'},
20
21
{id: 'Elsie Mcbride', height: '20', fill: '#64b5f6'},
22
{id:'Jude Mcbride'},
23
],
24
25
"edges":[
26
{from: 'Kate Austin', to:'Reece Gray'},
27
{from: 'Kate Austin', to:'Darren Burch'},
28
{from: 'Kate Austin', to:'Leslie Bailey'},
29
{from: 'Kate Austin', to:'Nova Fisher'},
30
{from: 'Kate Austin', to:'Jack Austin'},
31
32
{from: 'Jack Austin', to:'Jamie Montoya'},
33
{from: 'Jack Austin', to:'Sawyer Mack'},
34
{from: 'Jack Austin', to:'Hugo Love'},
35
{from: 'Jack Austin', to:'Sophie Lilly'},
36
{from: 'Jack Austin', to:'Elsie Mcbride'},
37
38
{from: 'Elsie Mcbride', to:'Jude Mcbride'},
39
40
{from: 'Sophie Lilly', to:'Ivy Mcintyre'},
41
{from: 'Sophie Lilly', to:'Evie West'},
42
]}
43
44
var chart = anychart.graph(data);
45
46
chart.title("Relationship Graph");
47
48
// configure nodes
49
chart.nodes().labels().enabled(true);
50
chart.nodes().labels().fontSize(12);
51
52
chart.nodes().normal().fill("white");
53
chart.nodes().normal().stroke("1 black");
54
chart.nodes().shape('circle');
55
56
chart.nodes().hovered().fill("white");
57
chart.nodes().hovered().stroke("2 black");
58
chart.nodes().hovered().shape('circle');
59
60
chart.layout().type('force');
61
62
// initiate drawing the chart
63
chart.container('container').draw();
64
});