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
var dataSet = anychart.data.set([
11
{'id': 'AU.WA', 'value': 300}, // Western Australia
12
{'id': 'AU.JB'}, // Jervis Bay Territory
13
{'id': 'AU.NS', 'value': 240}, // New South Wales
14
{'id': 'AU.VI', 'value': 75}, // Victoria
15
{'id': 'AU.NT', 'value': 130}, // Northern Territory
16
{'id': 'AU.TS', 'value': 190}, // Tasmania
17
{'id': 'AU.CT', labels: false}, // Australian Capital Territory
18
{'id': 'AU.SA'}, // South Australia
19
{'id': 'AU.QL'} // Queensland
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(dataSet);
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
});