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
// The data used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/samples/maps-bubble/bubble-earthquakes-map/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/maps-bubble/bubble-earthquakes-map/data.json',
6
function (data) {
7
// Creates data set
8
var dataSet = anychart.data.set(data);
9
10
// Creates Map Chart
11
var map = anychart.map();
12
13
// Sets geodata using https://cdn.anychart.com/geodata/latest/custom/world/world.js
14
map.geoData('anychart.maps.world');
15
16
map
17
.credits()
18
.enabled(true)
19
.url('https://en.wikipedia.org/wiki/Lists_of_earthquakes')
20
.text(
21
'Data source: https://en.wikipedia.org/wiki/Lists_of_earthquakes'
22
)
23
.logoSrc('https://en.wikipedia.org/static/favicon/wikipedia.ico');
24
25
// Sets Chart Title
26
map
27
.title()
28
.enabled(true)
29
.text('Strongest Earthquakes by Country')
30
.padding([0, 0, 20, 0]);
31
32
map.interactivity().selectionMode('none');
33
34
// Sets bubble max size settings
35
map.minBubbleSize('0.5%').maxBubbleSize('1.5%');
36
37
// Creates bubble series
38
map
39
.bubble()
40
.data(dataSet)
41
// Sets series settings
42
.geoIdField('iso_a2')
43
.fill('#ff8f00 0.6')
44
.stroke('1 #ff6f00 0.9');
45
map.hovered().fill('#78909c').stroke('1 #546e7a 1');
46
47
map
48
.tooltip()
49
.useHtml(true)
50
.title({ fontColor: '#7c868e' })
51
.padding([8, 13, 10, 13])
52
.format(function () {
53
var value =
54
'<span style="color: #545f69; font-size: 12px; font-weight: bold">';
55
var date =
56
'<br/><span style="color: #7c868e; font-size: 11px">';
57
var description =
58
'<br/><span style="color: #7c868e; font-size: 12px; font-style: italic">"';
59
if (this.getData('description') !== '') {
60
return (
61
value +
62
this.size +
63
'M </span></strong>' +
64
description +
65
this.getData('description') +
66
'"</span>' +
67
date +
68
this.getData('date') +
69
'</span>'
70
);
71
}
72
return (
73
value +
74
this.size +
75
'M </span></strong>' +
76
date +
77
this.getData('date') +
78
'</span>'
79
);
80
});
81
82
map
83
.tooltip()
84
.background()
85
.enabled(true)
86
.fill('#fff')
87
.stroke('#c1c1c1')
88
.corners(3)
89
.cornerType('round');
90
91
// create zoom controls
92
var zoomController = anychart.ui.zoom();
93
zoomController.render(map);
94
95
// Sets container id for the chart
96
map.container('container');
97
// Initiates chart drawing
98
map.draw();
99
}
100
);
101
});