HTMLcopy
1
<button id="backButton">Back</button>
2
<div id="container"></div>
CSScopy
24
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
#backButton {
14
visibility: hidden;
15
cursor: pointer;
16
background: #7bc0f7;
17
border: 1px solid #64b5f6;
18
color: #fff;
19
padding: 10px;
20
position: absolute;
21
top: 15px;
22
right: 20px;
23
z-index: 100;
24
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var 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
var 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
$("#backButton").css("visibility", "visible");
38
}
39
});
40
41
// load initial data on click
42
$("#backButton").on("click", function () {
43
chart.getSeries(0).data(data);
44
$("#backButton").css("visibility", "hidden");
45
});
46
47
// set container id and display chart
48
chart.container("container").draw();
49
});