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
// create data set
10
var dataSet = anychart.data.set([
11
['AU.NS', 3.5, 8.5],
12
['AU.NT', 7.1, 12],
13
['AU.WA', 10.4, 2.9],
14
['AU.SA', 4.7, 28.2],
15
['AU.VI', 7.9, 19.4],
16
['AU.QL', 8, 3.7],
17
['AU.TS', 3.2, 7.3]
18
]);
19
20
// create map chart
21
var map = anychart.map();
22
23
map.title("Employed international workers and \nUnemployed local workers");
24
25
// set geoData using https://cdn.anychart.com/geodata/1.2.0/countries/australia/australia.js
26
map.geoData(anychart.maps.australia);
27
28
var series1Data = dataSet.mapAs({id:[0], size:[1]});
29
var series2Data = dataSet.mapAs({id:[0], value:[2]});
30
31
//set bubble min/max size settings
32
map.maxBubbleSize(70);
33
map.minBubbleSize(20);
34
35
//create bubble series
36
var series_1 = map.bubble(series1Data);
37
series_1.name("Employed international workers");
38
var series_2 = map.choropleth(series2Data);
39
series_2.name("Unemployed local workers");
40
41
//set series geo id field settings
42
series_1.geoIdField("code_hasc");
43
series_2.geoIdField("code_hasc");
44
45
// change the fill and hoverFill colors of series_1
46
series_1.fill("#EBD670", 0.35);
47
series_1.hoverFill("#C7FF99", 0.7);
48
49
// change the stroke and hoverStroke colors of series_1
50
series_1.stroke("#C7FF99");
51
series_1.hoverStroke("#EBD670");
52
53
// set the select colors of series_1
54
series_1.selectStroke("#66FFCC");
55
series_1.selectFill("#879CED");
56
57
// set the select colors of series_2
58
series_2.selectStroke("#3675BD");
59
series_2.selectFill("#734CE6");
60
61
// set the labels
62
series_1.labels().fontColor('black');
63
series_1.labels().fontSize(10);
64
series_2.labels(false);
65
66
// tooltip formatting
67
series_1.tooltip().format(function(){
68
return ("Employed international workers: "+this.size+ "%");
69
});
70
71
series_2.tooltip().format(function(){
72
return ("Unemployed local workers: "+this.value+ "%");
73
});
74
75
// set the colors and ranges for the scale
76
series_2.colorScale(anychart.scales.linearColor());
77
78
//set the single hue progression
79
var colors = anychart.color.singleHueProgression('#0068BC');
80
81
// define the colors
82
series_2.colorScale().colors(colors);
83
84
// set container id for the chart
85
map.container('container');
86
87
// initiate chart drawing
88
map.draw();
89
});