HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// load data from a json file
4
anychart.data.loadJsonFile(
5
"https://gist.githubusercontent.com/shacheeswadia/8f45da54d9bf2032fee201dbfc79e0e4/raw/5d10d58f40b4a1d994cef36dbc64545ef90ead80/queenVisits.json",
6
function (data) {
7
8
// create a dataset
9
let dataSet = anychart.data.set(data);
10
11
// create a map instance
12
let map = anychart.map();
13
14
// set the geodata
15
map.geoData("anychart.maps.world");
16
17
// create a choropleth series
18
let series = map.choropleth(dataSet);
19
20
// set the map colors
21
series
22
.colorScale(
23
anychart.scales.linearColor("#f2f2f2", "#42a5f5", "#1976d2", "#233580")
24
);
25
26
// set the map title
27
map.title("State Visits Made by Queen Elizabeth II");
28
29
// set the container
30
map.container("container");
31
32
// initiate the map drawing
33
map.draw();
34
}
35
);
36
37
});