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(1).labels();
54
extraYLabels.format(function(){
55
return this.tickValue+"%";
56
});
57
58
// axis name
59
var yAxis_1 = chart_1.yAxis();
60
yAxis_1.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, 420, 600);
67
68
// draw
69
chart_1.container(stage);
70
chart_1.draw();
71
72
//chart 2
73
74
// set data
75
var data_2 = [
76
["Chocolate" , 3120],
77
["Cookies" , 5054],
78
["Marshmallows" , 10220],
79
["Sweets" , 2340],
80
["Macaroons" , 3421]
81
];
82
83
// set chart_2
84
var chart_2 = anychart.pie(data_2);
85
chart_2.innerRadius("30%");
86
87
var labels_2 = chart_2.labels();
88
labels_2.fontColor("White");
89
chart_2.title("Confectionery sold in Tea House");
90
91
// chart size and position
92
chart_2.bounds(420, 0, 245, 300);
93
94
// draw
95
chart_2.container(stage);
96
chart_2.draw();
97
98
//chart 3
99
100
// set data
101
var data_3 = [
102
["9.00 - 12.00", 9000],
103
["12.00 - 14.00", 12000],
104
["14.00 - 16.00", 13000],
105
["16.00 - 18.00", 15400],
106
["18.00 - 21.00", 9500]
107
];
108
109
// set chart_2
110
var chart_3 = anychart.bar(data_3);
111
chart_3.title("Popular hours");
112
113
// chart size and position
114
chart_3.bounds(420, 300, 245, 300);
115
116
// draw
117
chart_3.container(stage);
118
chart_3.draw();
119
});