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
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
mapData = [
10
{'id': 'AU.WA', 'capital': 'Perth', 'population': 1507949},
11
{'id': 'AU.JB', 'capital': 'Canberra', 'population': 377},
12
{'id': 'AU.NS', 'capital': 'Sydney', 'population': 4293105},
13
{'id': 'AU.VI', 'capital': 'Melbourne', 'population': 3800000},
14
{'id': 'AU.NT', 'capital': 'Darwin', 'population': 113955},
15
{'id': 'AU.TS', 'capital': 'Hobart', 'population': 205510},
16
{'id': 'AU.CT', 'capital': 'Canberra', 'population': 374766},
17
{'id': 'AU.SA', 'capital': 'Adelaide', 'population': 1138833},
18
{'id': 'AU.QL', 'capital': 'Brisbane', 'population': 1820375}
19
];
20
21
var map = anychart.map();
22
map.geoData(anychart.maps.australia);
23
map.title("Move mouse over the map to see tooltip");
24
// set the series
25
var series = map.choropleth(mapData);
26
27
//enable the tooltips and format them at once
28
series.tooltip().format(function(e){
29
return "Capital: " + e.getData("capital") +"\n"+
30
"Population: " + e.getData("population")
31
});
32
33
// disable the labels
34
series.labels(false);
35
36
// draw map
37
map.container("container");
38
map.draw();
39
});