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
{x: "John Doe", value: 1},
6
{x: "Richard Roe", value: 1},
7
{x: "Larry Loe", value: 1},
8
{x: "Marta Moe", value: 1},
9
{x: "Jane Poe", value: 1},
10
{x: "Norma Noe", value: 1},
11
{x: "William Woe", value: 1}
12
];
13
14
// create a chart and set the data
15
chart = anychart.pie(data);
16
17
// set the layout of the legend
18
chart.legend().itemsLayout("vertical");
19
20
// set the position of the legend
21
chart.legend().position("right");
22
23
// enable and configure the legend title
24
var title = chart.legend().title();
25
title.enabled(true);
26
title.text("Number of Employees: " + chart.getStat("count"));
27
title.orientation("left");
28
title.padding(5);
29
title.fontColor("#96a6a6");
30
title.fontSize(12);
31
title.fontWeight(600);
32
33
// enable and configure the title separator
34
var separator = chart.legend().titleSeparator()
35
separator.enabled(true);
36
separator.orientation("left");
37
separator.height(4);
38
separator.stroke("#96a6a6", 2);
39
separator.fill("none");
40
41
// set the chart title
42
chart.title("Legend: Title and Separator");
43
44
// set the container id
45
chart.container("container");
46
47
// initiate drawing the chart
48
chart.draw();
49
});