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: "Long-long-long legend item1", value: 637166},
6
{x: "Long-long-long legend item2", value: 721630},
7
{x: "Long-long-long legend item3", value: 148662},
8
{x: "Long-long-long legend item4", value: 78662},
9
{x: "Long-long-long legend item5", value: 90000}
10
];
11
12
// create a chart and set the data
13
var chart = anychart.pie(data);
14
15
var legend = chart.legend();
16
legend.itemsLayout('vertical-expandable');
17
legend.textOverflow('...');
18
legend.maxWidth(150);
19
20
21
// set the container id
22
chart.container("container").draw();
23
});