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", value: 5000},
6
{x: "Richard", value: 5000},
7
{x: "Larry", value: 5000},
8
{x: "Marta", value: 15000}
9
];
10
11
// create a chart and set the data
12
chart = anychart.pie(data);
13
14
// enable html for the legend
15
chart.legend().useHtml(true);
16
17
// configure the format of legend items
18
chart.legend().itemsFormat(
19
"<span style='color:#455a64;font-weight:600'>" +
20
"{%x}:</span> ${%value}"
21
);
22
23
// set the chart title
24
chart.title("Legend Items: Text Format (Tokens)" +
25
"\nSingle Series");
26
27
// set the container id
28
chart.container("container");
29
30
// initiate drawing the chart
31
chart.draw();
32
});