HTMLcopy
1
<button onclick="drillUp()">Drill Up</button>
2
<div id="container"></div>
CSScopy
15
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
10
#container {
11
position: absolute;
12
width: 100%;
13
top: 35px;
14
bottom: 0;
15
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// This sample uses 3rd party proj4 component
4
// that makes it possible to set coordinates
5
// for the points and labels on the map and
6
// required for custom projections and grid labels formatting.
7
// See https://docs.anychart.com/Maps/Map_Projections
8
9
// world map
10
chart = anychart.map();
11
12
// major maps
13
map = anychart.map();
14
15
// canada map
16
canadaMap = anychart.map();
17
18
worldDataSet = [
19
{id: "US", name: "USA", value: "1"},
20
{id: "CA", name: "Canada", value: "2", fill: "#FF9966"}
21
];
22
23
usaDataSet = [
24
{"id": "US.LA", "value": 22},
25
{"id": "US.TX", "value": 23},
26
{"id": "US.NY", "value": 45}
27
];
28
29
canadaDataSet = [
30
{"id": "CA.BC", "value": 3},
31
{"id": "CA.NF", "value": 11},
32
{"id": "CA.PE", "value": 12}
33
];
34
35
// world data and series
36
chart.geoData(anychart.maps.world);
37
worldSeries = chart.choropleth(worldDataSet);
38
39
// usa data and series
40
map.geoData(anychart.maps.united_states_of_america);
41
usaSeries = map.choropleth(usaDataSet);
42
43
// canada data and series
44
canadaMap.geoData(anychart.maps.canada);
45
canadaSeries = canadaMap.choropleth(canadaDataSet);
46
canadaSeries.fill("#FF9966");
47
48
// regions maps
49
txMap = anychart.map();
50
txMap.geoData(anychart.maps["texas"]);
51
52
laMap = anychart.map();
53
laMap.geoData(anychart.maps["louisiana"]);
54
55
nyMap = anychart.map();
56
nyMap.geoData(anychart.maps["new_york"]);
57
58
bcMap = anychart.map();
59
bcMap.geoData(anychart.maps["british_columbia"]);
60
61
nfMap = anychart.map();
62
nfMap.geoData(anychart.maps["newfoundland_and_labrador"]);
63
64
peMap = anychart.map();
65
peMap.geoData(anychart.maps["prince_edward_island"]);
66
67
// set the drillDownMaps
68
chart.drillDownMap({
69
"US": map,
70
"CA": canadaMap
71
});
72
73
map.drillDownMap({
74
"US.LA": laMap,
75
"US.TX": txMap,
76
"US.NY": nyMap
77
});
78
79
canadaMap.drillDownMap({
80
"CA.BC": bcMap,
81
"CA.NF": nfMap,
82
"CA.PE": peMap
83
});
84
85
// set the selectionMode
86
chart.interactivity({selectionMode: "drill-down"});
87
88
chart.container("container");
89
chart.draw();
90
});
91
92
// drill up
93
function drillUp() {
94
chart.drillUp();
95
}