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
var map = anychart.map();
10
// data sets for the series
11
var dataSet_1 =[
12
{'id': 'AU.JB', 'value': 1.5, "labelrank": 0, "middle-x": 0.5, "middle-y": 0.3, "middleXYMode": "relative"},
13
{'id': 'AU.NT', 'value': 2, "middle-y": 0.5, "middleXYMode": "relative"},
14
{'id': 'AU.WA', 'value': 3.2},
15
{'id': 'AU.NS', 'value': 2.7}
16
];
17
18
var dataSet_2 = [
19
{'id': 'AU.CT', 'value': 1.12, "labelrank": 9},
20
{'id': 'AU.SA', 'value': 2.9, "labelrank": 5, "middle-x": 0.5, "middle-y": 0.3, "middleXYMode": "relative"},
21
{'id': 'AU.VI', 'value': 3.86, "middle-x": 0.4, "middle-y": 0.6, "middleXYMode": "relative"},
22
{'id': 'AU.QL', 'value': 1.1, "middle-x": 0.4, "middle-y": 0.6, "middleXYMode": "relative"},
23
{'id': 'AU.TS', 'value': 1.6}
24
];
25
26
map.geoData("anychart.maps.australia");
27
28
// set the title and its preferences
29
map.title().useHtml(true).hAlign('center');
30
map.title('<span style="font-size: 14px;">Labels Settings</span><br><span style="font-size:12px;">Set custom position for inside labels through the data set</span>');
31
32
// set the series
33
var series_1 = map.choropleth(dataSet_1);
34
var series_2 = map.choropleth(dataSet_2);
35
36
// enable labels
37
map.labels(true);
38
// set the overlapping mode for the map
39
map.overlapMode(false);
40
41
// set the tooltips
42
series_1.tooltip().format("More women");
43
series_2.tooltip().format("More men");
44
45
// set the container
46
map.container('container');
47
map.draw();
48
});