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
["John", 10000, 12500],
6
["Jake", 12000, 15000],
7
["Peter", 13000, 16500],
8
["James", 10000, 13500],
9
["Mary", 9000, 11000]
10
]);
11
12
// map the data
13
var seriesData_1 = data.mapAs({x: 0, value: 1});
14
var seriesData_2 = data.mapAs({x: 0, value: 2});
15
16
// set the chart type
17
var chart = anychart.column();
18
19
// create the first series, set the data and name
20
var series1 = chart.column(seriesData_1);
21
series1.name("Sales in 2015");
22
23
// create the second series, set the data and name
24
var series2 = chart.column(seriesData_2);
25
series2.name("Sales in 2016");
26
27
// enable the legend
28
chart.legend(true);
29
30
// set the chart title
31
chart.title("Legend");
32
33
// set the titles of the axes
34
chart.xAxis().title("Manager");
35
chart.yAxis().title("Sales, $");
36
37
// set the container id
38
chart.container("container");
39
40
// initiate drawing the chart
41
chart.draw();
42
});