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: "Richard", group: "family"},
7
{id: "Larry", group: "family"},
8
{id: "Marta", group: "family"},
9
{id: "Jane", group: "friends"},
10
{id: "Norma", group: "friends"},
11
{id: "Frank", group: "friends"},
12
{id: "Brett", group: "friends"},
13
{id: "Tommy", group: "lone wolf"}
14
],
15
edges: [
16
{from: "Richard", to: "Larry"},
17
{from: "Richard", to: "Marta"},
18
{from: "Larry", to: "Marta"},
19
{from: "Marta", to: "Jane"},
20
{from: "Jane", to: "Norma"},
21
{from: "Jane", to: "Frank"},
22
{from: "Jane", to: "Brett"},
23
{from: "Brett", to: "Frank"}
24
]
25
};
26
27
// create a chart and set the data
28
var chart = anychart.graph(data);
29
30
// prevent zooming the chart with the mouse wheel
31
chart.interactivity().zoomOnMouseWheel(false);
32
33
// configure the visual settings of edges
34
chart.edges().normal().stroke("#ffa000", 2, "10 5", "round");
35
chart.edges().hovered().stroke("#ffa000", 4, "10 5", "round");
36
chart.edges().selected().stroke("#ffa000", 4);
37
38
// set the chart title
39
chart.title("Network Graph: Edges");
40
41
// set the container id
42
chart.container("container");
43
44
// initiate drawing the chart
45
chart.draw();
46
});