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
// create data set on our data
3
var dataSet = anychart.data.set([
4
['1988-1990', 211, 1603, 0],
5
['1995', 415, 7925, 2792],
6
['2000', 391, 2762, 2398],
7
['2005', 970, 6840, 3300],
8
['2010', 1237, 19886, 11000],
9
['2015', 2120, 24115, 14500],
10
['2016', 2613, 26890, 15800],
11
['2017', 2741, 37100, 17500],
12
['20/09/2018', 2182, 25370, 13250]
13
]);
14
15
// map data for the first series, take x from the zero column and value from the first column of data set
16
var seriesData_1 = dataSet.mapAs({'x': 0, 'value': 1});
17
18
// map data for the second series, take x from the zero column and value from the second column of data set
19
var seriesData_2 = dataSet.mapAs({'x': 0, 'value': 2});
20
21
// map data for the second series, take x from the zero column and value from the second column of data set
22
var seriesData_3 = dataSet.mapAs({'x': 0, 'value': 3});
23
24
// create column chart
25
var chart = anychart.column3d();
26
27
// turn on chart animation
28
chart.animation(true);
29
30
// set chart title text settings
31
chart.title('Top 10 Products by Revenue in three Regions');
32
33
// temp variable to store series instance
34
var series;
35
36
// helper function to setup label settings for all series
37
var setupSeries = function (series, name) {
38
series.name(name);
39
series.selected()
40
.fill('#f48fb1 0.8')
41
.stroke('1.5 #c2185b');
42
};
43
44
// create first series with mapped data
45
series = chart.column(seriesData_1);
46
series.xPointPosition(0.25);
47
setupSeries(series, 'Florida');
48
49
// create second series with mapped data
50
series = chart.column(seriesData_2);
51
series.xPointPosition(0.45);
52
setupSeries(series, 'Texas');
53
54
// create second series with mapped data
55
series = chart.column(seriesData_3);
56
series.xPointPosition(0.65);
57
setupSeries(series, 'Mexico');
58
59
chart.yAxis().labels().format('{%Value}{groupsSeparator: }');
60
61
// set titles for Y-axis
62
chart.yAxis().title('Revenue in Dollars');
63
64
// set chart title text settings
65
chart.barGroupsPadding(0.3);
66
67
// turn on legend
68
chart.legend()
69
.enabled(true)
70
.fontSize(13)
71
.padding([0, 0, 20, 0]);
72
73
chart.interactivity().hoverMode('single');
74
75
chart.tooltip().valuePrefix('$');
76
77
// set container id for the chart
78
chart.container('container');
79
80
// initiate chart drawing
81
chart.draw();
82
});