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 dataSet = anychart.data.set([
10
{'id': 'AU.WA', 'value': 300}, // Western Australia
11
{'id': 'AU.NS', 'value': 240}, // New South Wales
12
{'id': 'AU.VI', 'value': 75}, // Victoria
13
{'id': 'AU.NT', 'value': 130}, // Northern Territory
14
{'id': 'AU.TS', 'value': 190}, // Tasmania
15
{'id': 'AU.CT', labels: false} // Australian Capital Territory
16
]);
17
18
var map = anychart.map();
19
map.geoData(anychart.maps.australia);
20
21
// set the fill for the regions you haven't defined in the dataSet
22
map.unboundRegions().fill('#eee');
23
24
// set the background color
25
// map.background('Gainsboro');
26
// set the title and its preferences
27
map.title().useHtml(true).hAlign('center');
28
map.title('<span style="font-size: 18px;">Data Setting</span><br><span style="font-size:12px;">Move the mouse over the districts to see which have values</span>');
29
30
// set the series
31
var series = map.choropleth(dataSet);
32
series.geoIdField('code_hasc');
33
series.labels().fontColor('black');
34
35
// set the container
36
map.container('container');
37
map.draw();
38
});