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 a data set
4
var data = anychart.data.set([
5
["Jane", 10000],
6
["John", 5000],
7
["Bill", 7000]
8
]);
9
10
// map the data
11
var seriesData = data.mapAs({x: 0, value: 1});
12
13
// create a chart
14
var chart = anychart.column();
15
16
// create a series, set the data and name
17
var series = chart.column(seriesData);
18
series.name("Sales");
19
20
// enable the legend
21
chart.legend(true);
22
23
// set the source mode of the legend
24
chart.legend().itemsSourceMode("categories");
25
26
// set the chart title
27
chart.title("Legend: Source = categories");
28
29
// set the container id
30
chart.container("container");
31
32
// initiate drawing the chart
33
chart.draw();
34
});