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
var stage = anychart.graphics.create("container");
4
5
// data
6
var dataSet = anychart.data.set([
7
["Department Stores", 637166, 254463, 353554, 856175],
8
["Discount Stores", 721630, 366655, 734634, 365654],
9
["Men's/Women's Specialty Stores", 148662, 252522, 123488, 903112],
10
["All other outlets", 90000, 61000, 72000, 94000, 83000]
11
]);
12
13
// apply custom themes
14
anychart.theme([barTheme, columnTheme, splineTheme]);
15
16
// create charts
17
barChart = anychart.bar();
18
columnChart = anychart.column();
19
splineChart = anychart.line();
20
21
seriesData_1 = dataSet.mapAs({x: 0, value: 1});
22
seriesData_2 = dataSet.mapAs({x: 0, value: 2});
23
seriesData_3 = dataSet.mapAs({x: 0, value: 3});
24
seriesData_4 = dataSet.mapAs({x: 0, value: 4});
25
26
seriesBar = barChart.bar(seriesData_1);
27
seriesBar.fill("#cac4b0");
28
seriesBar.stroke(null);
29
30
columnChart.column(seriesData_1);
31
columnChart.column(seriesData_3);
32
33
splineChart.spline(seriesData_1);
34
splineChart.spline(seriesData_2);
35
splineChart.spline(seriesData_3);
36
splineChart.spline(seriesData_4);
37
38
// set container and draw charts
39
barChart.container(stage);
40
barChart.draw();
41
columnChart.container(stage);
42
columnChart.draw();
43
splineChart.container(stage);
44
splineChart.draw();
45
});
46
47
barTheme = {
48
"bar": {
49
"defaultXAxisSettings": {
50
"title": "Retail Channel"
51
},
52
"defaultYAxisSettings": {
53
"title": "Sales"
54
},
55
"background":{
56
"fill": "#999999 .1"
57
},
58
"bounds": [0, 0, '50%', '50%']
59
},
60
"defaultTitle": {
61
"enabled": true,
62
"hAlign": "left"
63
},
64
"defaultTooltip": {
65
"enabled": true,
66
"title": false,
67
"separator": false
68
},
69
"chart": {
70
"title": {
71
"text": "Bar Chart",
72
"fontSize": 20,
73
"fontColor": "black"
74
}
75
}
76
};
77
78
columnTheme = {
79
"column": {
80
"defaultXAxisSettings": {
81
"title": "Retail Channel"
82
},
83
"defaultYAxisSettings": {
84
"title": "Sales"
85
},
86
"background":"#999999 .1",
87
"palette": {
88
"type": "distinct",
89
"items": ["#9f8170", "#828282"]
90
},
91
"bounds": ['50%', 0, '50%', '50%']
92
},
93
"chart": {
94
"title": {
95
"text": "Bar and Column Charts",
96
"fontSize": 18,
97
"fontColor": "red",
98
"align": "right"
99
},
100
"tooltip":{
101
"displayMode": "separated"
102
}
103
}
104
};
105
106
splineTheme = {
107
"line": {
108
"defaultXAxisSettings": {
109
"title": "Retail Channel"
110
},
111
"defaultYAxisSettings": {
112
"title": "Sales"
113
},
114
"background":{
115
"fill": "#999999 .1"
116
},
117
"palette": {
118
"type": "distinct",
119
"items": ["#9f8170", "#000", "#911e42", "#21421e"]
120
},
121
"bounds": [0, '50%', '100%', '50%']
122
},
123
"chart": {
124
"title": {
125
"text": "Bar, Column and Spline Charts",
126
"fontSize": 16,
127
"fontColor": "#c1876b",
128
"align": "center"
129
},
130
"tooltip":{
131
"displayMode": "union",
132
"positionMode": "point"
133
}
134
}
135
};