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': 170}, // Western Australia
11
{'id': 'AU.NS', 'value': 260}, // New South Wales
12
{'id': 'AU.VI', 'value': 75}, // Victoria
13
{'id': 'AU.NT', 'value': 130}, // Northern Territory
14
{'id': 'AU.TS', 'value': 210}, // 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
// stroke the undefined regions
22
map.unboundRegions().stroke('green');
23
24
map.title().useHtml(true).hAlign('center');
25
map.title('<span style="font-size: 18px;">Ordinal Color Scale <br> Single Hue Color Progression');
26
27
// set the colorRange preferences
28
var cr = map.colorRange();
29
cr.colorLineSize(15);
30
cr.align('center');
31
cr.stroke(null);
32
cr.ticks().stroke('rgb(216,216,216)');
33
cr.ticks().position('center').length(15);
34
35
series = map.choropleth(dataSet);
36
series.geoIdField('code_hasc');
37
series.stroke('#000 .3');
38
series.labels().fontColor('black');
39
40
// define the color of the hovered district
41
series.selectFill('#5588ff');
42
43
// making of the ordinal colorRange
44
ocs = anychart.scales.ordinalColor([
45
{less: 100},
46
{from: 100, to: 150},
47
{from: 150, to: 200},
48
{from: 200, to: 350},
49
{greater: 250}
50
]);
51
ocs.colors(['rgb(253,225,86)', 'rgb(248,196,57)', 'rgb(244,168,19)', 'rgb(198,109,1)', 'rgb(152,58,0)']);
52
53
// tell the series what to use as a colorRange (colorScale)
54
series.colorScale(ocs);
55
56
map.container('container');
57
map.draw();
58
});