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
11
// data set for the choropleth series
12
var data_1 =[
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 data_2 = [
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(data_1);
35
var series_2 = map.choropleth(data_2);
36
37
// enable labels
38
map.labels(true);
39
40
// set the overlapping mode for the map
41
map.overlapMode("no-overlap");
42
43
// set tooltips
44
series_1.tooltip().format("More women");
45
series_2.tooltip().format("More men");
46
47
// create callouts
48
calloutRight = map.callout(0);
49
calloutBottom = map.callout(1);
50
51
// set connectors stroke color
52
calloutRight.labels().connectorStroke('navy');
53
calloutBottom.labels().connectorStroke('navy');
54
55
// set regions
56
calloutBottom.items(["AU.CT"]);
57
calloutRight.items(["AU.JB"]);
58
59
// set callouts positions
60
calloutBottom.orientation("bottom");
61
calloutRight.orientation("right");
62
63
// set the label text position
64
calloutBottom.align("center");
65
calloutRight.align("center");
66
67
// set width and length
68
calloutBottom.width(50);
69
calloutBottom.length(300);
70
calloutRight.width(70);
71
calloutRight.length(100);
72
73
// set the container
74
map.container('container');
75
map.draw();
76
});