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
// set chart type
4
var chart = anychart.column();
5
6
// legend settings
7
var legend = chart.legend();
8
// enable legend
9
legend.enabled(true);
10
// set source of legend items
11
legend.itemsSourceMode("categories");
12
13
// set data
14
var series = chart.column([
15
{x: "John", value: 10000},
16
{x: "Jake", value: 12000},
17
{x: "Peter", value: 16000}
18
]);
19
20
series.name("Sales");
21
22
// set chart title
23
chart.title("Legend for Single Series");
24
25
// set container and draw chart
26
chart.container("container");
27
chart.draw();
28
});