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 set on our data
4
var dataSet = anychart.data.set([
5
["Jan", 10, 30],
6
["Feb", 12, 32],
7
["Mar", 11, 35],
8
["Apr", 15, 40],
9
["May", 20, 42],
10
["Jun", 22, 35],
11
["Jul", 21, 36],
12
["Aug", 28, 40],
13
["Sep", 29, 42],
14
["Okt", 40, 40],
15
["Nov", 41, 38],
16
["Dec", 45, 40]
17
]);
18
19
// map data for the first series, take x from the zero column and value from the first column of data set
20
var seriesData_1 = dataSet.mapAs({x: 0, value: 1});
21
22
// map data for the second series, take x from the zero column and value from the second column of data set
23
var seriesData_2 = dataSet.mapAs({x: 0, value: 2});
24
25
// create line chart
26
var chart = anychart.column();
27
28
// adding dollar symbols to yAxis labels
29
var yLabels = chart.yAxis().labels();
30
yLabels.format("${%value}");
31
32
// turn on chart animation
33
chart.animation(true);
34
35
// set chart title text settings
36
chart.title(false);
37
38
// create first series with mapped data
39
var series_1 = chart.column(seriesData_1);
40
series_1.name("ACME Corp. Share Price");
41
42
// create second series with mapped data
43
var series_2 = chart.column(seriesData_2);
44
series_2.name("Sirius Cybernetics Corp. Share Price");
45
46
// turn the legend on
47
var legend = chart.legend();
48
legend.enabled(true);
49
legend.align("center");
50
legend.fontSize(13);
51
52
// making series_1 and some points of series_2 selected
53
series_1.select();
54
series_2.select([0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 16, 17, 18, 20]);
55
56
series_1.selected().stroke(null);
57
series_1.selected().hatchFill("diagonal", "#ddd", 1, 5);
58
series_2.selected().hatchFill("confetti", "#fff", 1, 5);
59
series_2.selected().stroke(null);
60
61
// set container id for the chart
62
chart.container("container");
63
64
// initiate chart drawing
65
chart.draw();
66
});