HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 200px;
5
height: 400px;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// create data set on our data
3
var dataSet = anychart.data.set([
4
['Reynaers', 12814, 3054],
5
['Roval', 10814, 20123]
6
]);
7
8
// map data for the first series, take x from the zero column and value from the first column of data set
9
var firstSeriesData = dataSet.mapAs({ x: 0, value: 1 });
10
11
// map data for the second series, take x from the zero column and value from the second column of data set
12
var secondSeriesData = dataSet.mapAs({ x: 0, value: 2 });
13
14
// create bar chart
15
var chart = anychart.column3d();
16
17
// force chart to stack values by Y scale.
18
chart.yScale().stackMode('percent');
19
20
// turn on chart animation
21
chart.animation(true);
22
23
// set chart title text settings
24
chart.title('');
25
26
chart.contextMenu(false);
27
28
// set yAxis labels formatting, force it to add % to values
29
chart.yAxis(0).labels().format('');
30
31
// helper function to setup label settings for all series
32
var setupSeries = function (series, name) {
33
series.name(name).stroke('2 #fff 1');
34
series.hovered().stroke('2 #fff 1');
35
};
36
37
// temp variable to store series instance
38
var series;
39
40
// create first series with mapped data
41
series = chart.column(firstSeriesData);
42
setupSeries(series, 'Florida');
43
44
// create second series with mapped data
45
series = chart.column(secondSeriesData);
46
setupSeries(series, 'Texas');
47
48
var tooltip = series.tooltip();
49
tooltip.enabled(false);
50
51
chart.interactivity().hoverMode('by-x');
52
chart.tooltip().displayMode('union');
53
54
// turn on legend
55
chart.legend().enabled(false);
56
57
// set container id for the chart
58
chart.container('container');
59
// initiate chart drawing
60
chart.draw();
61
});