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/7.14.3/Maps/Map_Projections
8
9
var map = anychart.map();
10
11
// data set for the choropleth series
12
var dataSet_1 = anychart.data.set([
13
{'id': 'AU.JB', 'value': 1.5, label:{format: "Jervis \nBay \nTerritory", fontColor: "white"}},
14
{'id': 'AU.NT', 'value': 2},
15
{'id': 'AU.WA', 'value': 3.2},
16
{'id': 'AU.NS', 'value': 2.7}
17
]);
18
19
var dataSet_2 = anychart.data.set([
20
{'id': 'AU.CT', 'value': 1.12, label:{fontColor: "white"}},
21
{'id': 'AU.SA', 'value': 2.9},
22
{'id': 'AU.VI', 'value': 3.86},
23
{'id': 'AU.QL', 'value': 1.1},
24
{'id': 'AU.TS', 'value': 1.6}
25
]);
26
27
map.geoData("anychart.maps.australia");
28
29
// set the title and its preferences
30
map.title().useHtml(true).hAlign('center');
31
map.title('<span style="font-size:14px;">Callout</span><br><span style="font-size:12px;">Adjust label settings</span>');
32
33
// set the series
34
var series_1 = map.choropleth(dataSet_1);
35
var series_2 = map.choropleth(dataSet_2);
36
37
// enable labels
38
series_1.labels(true);
39
series_2.labels(true);
40
41
// set the overlapping mode for the map
42
map.overlapMode("noOverlap");
43
44
// set tooltips
45
series_1.tooltip().format("More women");
46
series_2.tooltip().format("More men");
47
48
// create callouts
49
calloutRight = map.callout(0);
50
calloutBottom = map.callout(1);
51
52
// set connectors stroke color
53
calloutRight.labels().connectorStroke('navy');
54
calloutBottom.labels().connectorStroke('navy');
55
56
// set regions
57
calloutBottom.items(["AU.CT"]);
58
calloutRight.items(["AU.JB"]);
59
60
// set callouts positions
61
calloutBottom.orientation("bottom");
62
calloutRight.orientation("right");
63
64
// set the label text position
65
calloutBottom.align("center");
66
calloutRight.align("center");
67
68
// set width and length
69
calloutBottom.width(50);
70
calloutBottom.length(300);
71
calloutRight.width(70);
72
calloutRight.length(100);
73
74
// set the container
75
map.container('container');
76
map.draw();
77
});