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 stage
4
var stage = anychart.graphics.create("container");
5
6
// create variable for custom theme
7
var customTheme = {
8
"defaultFontSettings": {
9
"fontSize": 9
10
},
11
"chart": {
12
"title": false,
13
"legend": false
14
}
15
};
16
17
// apply custom theme
18
anychart.theme(customTheme);
19
20
// set data
21
var data_1 = anychart.data.set([
22
["Green", 10000, 30],
23
["Red", 15000, 80],
24
["Herbal", 16000, 50],
25
["Black", 19000, 35],
26
["Berry", 9000, 49]
27
]);
28
29
// set data
30
var seriesData_1 = data_1.mapAs({x: [0], value: [1]});
31
var seriesData_2 = data_1.mapAs({x: [0], value: [2]});
32
33
// set chart_1
34
var chart_1 = anychart.column();
35
36
chart_1.column(seriesData_1);
37
38
//create scale for line series and extraYAxis
39
//it force line series to not stuck values with over series
40
var scale = anychart.scales.linear();
41
scale.minimum(0);
42
scale.maximum(100);
43
44
//create line series and set scale for it
45
var lineSeries = chart_1.spline(seriesData_2);
46
lineSeries.yScale(scale);
47
48
//create extra axis on the right side of chart
49
var extraYAxis = chart_1.yAxis(1);
50
extraYAxis.title("Customers under 20 years old");
51
extraYAxis.orientation("right");
52
extraYAxis.scale(scale);
53
var extraYLabels = chart_1.yAxis().labels();
54
extraYLabels.format(function(){
55
return this.tickValue+"%";
56
});
57
58
// axis name
59
var yAxis = chart_1.yAxis();
60
yAxis.title("Sales (.oz)");
61
62
// set chart title
63
chart_1.title("Popular Tea Types in the Tea House");
64
65
// chart size and position
66
chart_1.bounds(0, 0, "60%", "100%");
67
68
// draw
69
chart_1.container(stage);
70
chart_1.draw();
71
72
73
//chart 2
74
75
// set data
76
var data_2 = [
77
["Chocolate", 3120],
78
["Cookies", 5054],
79
["Marshmallows", 10220],
80
["Sweets", 2340],
81
["Macaroons", 3421]
82
];
83
84
// set chart_2
85
var chart_2 = anychart.pie(data_2);
86
chart_2.innerRadius("30%");
87
88
var labels_2 = chart_2.labels();
89
labels_2.fontColor("White");
90
chart_2.title("Confectionery sold in Tea House");
91
92
// chart size and position
93
chart_2.bounds("60%", 0, "35%", "40%");
94
95
// draw
96
chart_2.container(stage);
97
chart_2.draw();
98
99
//chart 3
100
101
// set data
102
var data_3 = [
103
["9.00 - 12.00", 9000],
104
["12.00 - 14.00", 12000],
105
["14.00 - 16.00", 13000],
106
["16.00 - 18.00", 15400],
107
["18.00 - 21.00", 9500]
108
];
109
110
// set chart_2
111
var chart_3 = anychart.bar(data_3);
112
chart_3.title("Popular hours");
113
114
// chart size and position
115
chart_3.bounds("60%", "40%", "35%", "60%");
116
117
// draw
118
chart_3.container(stage);
119
chart_3.draw();
120
});