HTMLcopy
1
<button id="backButton" onclick="back()">Back</button>
2
<div id="container"></div>
CSScopy
x
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
#container {
8
position: absolute;
9
width: 100%;
10
top: 25px;
11
bottom: 0;
12
}
13
14
button {
15
visibility: hidden;
16
cursor: pointer;
17
background: #7bc0f7;
18
border: 1px solid #64b5f6;
19
color: #fff;
20
padding: 10px;
21
position: absolute;
22
top: 15px;
23
right: 20px;
24
z-index: 100;
25
}
JavaScriptcopy
49
1
anychart.onDocumentReady(function () {
2
data = [
3
{"x": 2015, "value": 2195081, "drillDown": [
4
{"x": "Q1", "value": 792026},
5
{"x": "Q2", "value": 610501},
6
{"x": "Q3", "value": 441843},
7
{"x": "Q4", "value": 350711}
8
]},
9
{"x": 2016, "value": 3257447, "drillDown": [
10
{"x": "Q1", "value": 1378786},
11
{"x": "Q2", "value": 571063},
12
{"x": "Q3", "value": 510493},
13
{"x": "Q4", "value": 797105}
14
]},
15
{"x": 2017, "value": 1963407, "drillDown": [
16
{"x": "Q1", "value": 499299},
17
{"x": "Q2", "value": 649963},
18
{"x": "Q3", "value": 571176},
19
{"x": "Q4", "value": 242969}
20
]}
21
];
22
23
// create column chart
24
chart = anychart.column(data);
25
26
// configure axis labels
27
chart.yAxis().labels().format('${%value}{scale:(1000)(1000)|(k)(m)}');
28
// tune tooltips format
29
chart.tooltip().format('${%value}');
30
// tune interactivity selection mode
31
chart.interactivity().selectionMode('none');
32
33
// configire drilldown on point click
34
chart.listen('pointClick', function (e) {
35
if (e.point.get('drillDown')) {
36
chart.getSeries(0).data(e.point.get('drillDown'));
37
document.getElementById("backButton").style.visibility = "visible";
38
}
39
});
40
41
// set container id and display chart
42
chart.container('container').draw();
43
});
44
45
// load initial data on button click
46
function back() {
47
chart.getSeries(0).data(data);
48
document.getElementById("backButton").style.visibility = "hidden";
49
}