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 set for the choropleth series
11
var data_1 = [
12
{'id': 'AU.JB', 'value': 1.5},
13
{'id': 'AU.NT', 'value': 2},
14
{'id': 'AU.WA', 'value': 3.2},
15
{'id': 'AU.NS', 'value': 2.7}
16
];
17
18
var data_2 = [
19
{'id': 'AU.CT', 'value': 1.12},
20
{'id': 'AU.SA', 'value': 2.9},
21
{'id': 'AU.VI', 'value': 3.86},
22
{'id': 'AU.QL', 'value': 1.1},
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;">Callout</span><br><span style="font-size:12px;">Set and format the callout labels</span>');
31
32
// set the series
33
var series_1 = map.choropleth(data_1);
34
var series_2 = map.choropleth(data_2);
35
36
// enable labels
37
map.labels(true);
38
39
// set the overlapping mode for the map
40
map.overlapMode(false);
41
42
// set the tooltips
43
series_1.tooltip().format("More women");
44
series_2.tooltip().format("More men");
45
46
// create the callout
47
calloutRight = map.callout(0);
48
calloutBottom = map.callout(1);
49
50
// set the connector stroke color
51
calloutRight.labels().connectorStroke('navy');
52
calloutBottom.labels().connectorStroke('navy');
53
54
// set regions
55
calloutBottom.items(["AU.CT"]);
56
calloutRight.items(["AU.JB"]);
57
58
// set position
59
calloutBottom.orientation("bottom");
60
calloutRight.orientation("right");
61
62
// set the label text position
63
calloutBottom.align("center");
64
calloutRight.align("center");
65
66
// set width and length
67
calloutBottom.width(50);
68
calloutBottom.length(300);
69
calloutRight.width(70);
70
calloutRight.length(100);
71
72
// set the container
73
map.container('container');
74
map.draw();
75
});