forked from highcharts/highcharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld-map.htm
135 lines (113 loc) · 3.54 KB
/
world-map.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "https://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<!-- 1. Add these JavaScript inclusions in the head of your page -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/3.0.1/highcharts.js"></script>
<script type="text/javascript" src="https://github.highcharts.com/75c66eb3/modules/map.src.js"></script>
<script type="text/javascript" src="https://github.highcharts.com/75c66eb3/modules/data.src.js"></script>
<!-- 2. Insert the shapes -->
<script type="text/javascript" src="world-map-shapes.js"></script>
<!-- 3. Add the JavaScript to initialize the chart on document ready -->
<script type="text/javascript">
var chart;
$(function() {
// Load the data from a Google Spreadsheet
// https://docs.google.com/a/highsoft.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0AoIaUO7wH1HwdFJHaFI4eUJDYlVna3k5TlpuXzZubHc&output=html
Highcharts.data({
googleSpreadsheetKey: '0AoIaUO7wH1HwdFJHaFI4eUJDYlVna3k5TlpuXzZubHc',
// custom handler when the spreadsheet is parsed
parsed: function(columns) {
// Make the columns easier to read
var countryCodes = columns[0],
countryNames = columns[1],
populationDensities = columns[2];
var options = {
chart : {
renderTo : 'container',
borderWidth : 1,
zoomType: 'xy'
},
title : {
text : 'Population density by country (/km²)'
},
subtitle: {
text: 'This is a work in progress'
},
legend: {
align: 'left',
verticalAlign: 'bottom',
floating: true,
layout: 'vertical',
valueDecimals: 0
},
tooltip: {
ySuffix: '/km²'
},
series : [{
data : [],
name: 'Population density',
valueRanges: [{
to: 3,
color: 'rgba(19,64,117,0.05)'
}, {
from: 3,
to: 10,
color: 'rgba(19,64,117,0.2)'
}, {
from: 10,
to: 30,
color: 'rgba(19,64,117,0.4)'
}, {
from: 30,
to: 100,
color: 'rgba(19,64,117,0.5)'
}, {
from: 100,
to: 300,
color: 'rgba(19,64,117,0.6)'
}, {
from: 300,
to: 1000,
color: 'rgba(19,64,117,0.8)'
}, {
from: 1000,
color: 'rgba(19,64,117,1)'
}],
states: {
hover: {
color: '#DD6E28'
}
}
}]
};
// Populate the data points
//countryCodes = countryCodes.splice(0, 3);
for (var i = 1; i < countryCodes.length; i++) {
if (shapes[countryCodes[i]]) {
options.series[0].data.push({
y : parseFloat(populationDensities[i]),
name : countryNames[i],
path : Highcharts.pathToArray(shapes[countryCodes[i]]),
states: {
hover: {
color: '#FF7F00' // orange
}
}
});
}
}
// Initiate the chart
chart = new Highcharts.Map(options);
}
});
});
</script>
</head>
<body>
<!-- 3. Add the container -->
<div id="container" style="width: 800px; height: 500px; margin: 0 auto"></div>
</body>
</html>