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
var data = [
3
// column 0 1 2 3
4
["2014/6/25", 28, 23, 28], // row 0
5
["2014/6/26", 26, 21, 26], // 1
6
["2014/6/27", 27, 19, 26], // 2
7
["2014/6/28", 25, 21, 27], // 3
8
["2014/6/29", 29, 22, 28], // 4
9
["2014/6/30", 28, 25, 27] // 5
10
];
11
12
// create a data set
13
var dataSet = anychart.data.set(data);
14
15
// set stage
16
var stage = anychart.graphics.create("container");
17
18
// create a line chart using the data set
19
var line = anychart.line.apply(null, anychart.data.mapAsTable(data));
20
21
// axes labels
22
line.yAxis().labels().format("{%Value}?C");
23
// series titles setter
24
line.getSeries(0).name("NY");
25
line.getSeries(1).name("SF");
26
line.getSeries(2).name("LA");
27
28
// naming the chart
29
line.title("Weather in the USA");
30
31
// set container and position
32
line.container(stage);
33
line.bounds(0, 0, "100%", "50%");
34
35
// initiate chart drawing
36
line.draw();
37
38
// map x and value from the data set
39
var colChart = anychart.column.apply(null, anychart.data.mapAsTable(data));
40
41
// naming the chart's series (legend)
42
colChart.getSeries(0).name("NY");
43
colChart.getSeries(1).name("SF");
44
colChart.getSeries(2).name("LA");
45
46
// axes labels set
47
colChart.yAxis().labels().format("{%Value}?C");
48
49
// naming the chart
50
colChart.title("Weather in the USA");
51
52
// set container and position
53
colChart.container(stage);
54
colChart.bounds(0, "50%", "100%", "50%");
55
56
// draw
57
colChart.draw();
58
});