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
var data = [
11
{'id': 'AU.WA', 'value': 300},
12
{'id': 'AU.JB'},
13
{'id': 'AU.NS', 'value': 240},
14
{'id': 'AU.VI', 'value': 75},
15
{'id': 'AU.NT', 'value': 130},
16
{'id': 'AU.TS', 'value': 190},
17
{'id': 'AU.CT', labels: false},
18
{'id': 'AU.SA'},
19
{'id': 'AU.QL'}
20
];
21
22
map.geoData(anychart.maps.australia);
23
24
// set the title and its preferences
25
map.title().useHtml(true).hAlign('center');
26
map.title('<span style="font-size: 18px;">Data Setting</span><br><span style="font-size:12px;">Labels on a map</span>');
27
28
// set the series
29
var series = map.choropleth(data);
30
// enable labels
31
series.labels(true);
32
labels = series.labels();
33
34
// labels setting
35
labels.fontColor('black');
36
labels.fontSize("10px");
37
labels.offsetY(-10);
38
39
// set the container
40
map.container('container');
41
map.draw();
42
});