-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
83 lines (80 loc) · 2.68 KB
/
test.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Maps</title>
<link rel="stylesheet" media="all" href="../jvectormap/jquery-jvectormap.css"/>
<link rel="stylesheet" media="all" href="css/jquery-ui-1.8.21.custom.css"/>
<script src="../jvectormap/tests/assets/jquery-1.8.2.min.js"></script>
<script src="../jvectormap.min.js"></script>
<script src="../jvectormap/tests/assets/jquery-jvectormap-us-aea-en.js"></script>
<script src="jquery-ui-1.8.21.custom.min.js"></script>
<script>
$(function(){
$.getJSON('/data/us-unemployment.json', function(data){
var val = 2009;
statesValues = jvm.values.apply({}, jvm.values(data.states)),
metroPopValues = Array.prototype.concat.apply([], jvm.values(data.metro.population)),
metroUnemplValues = Array.prototype.concat.apply([], jvm.values(data.metro.unemployment));
$('#world-map-gdp').vectorMap({
map: 'us_aea_en',
markers: data.metro.coords,
series: {
markers: [{
attribute: 'fill',
scale: ['#FEE5D9', '#A50F15'],
values: data.metro.unemployment[val],
min: jvm.min(metroUnemplValues),
max: jvm.max(metroUnemplValues)
},{
attribute: 'r',
scale: [5, 20],
values: data.metro.population[val],
min: jvm.min(metroPopValues),
max: jvm.max(metroPopValues)
}],
regions: [{
scale: ['#DEEBF7', '#08519C'],
attribute: 'fill',
values: data.states[val],
min: jvm.min(statesValues),
max: jvm.max(statesValues)
}]
},
onMarkerLabelShow: function(event, label, index){
label.html(
''+data.metro.names[index]+''+
'Population: '+data.metro.population[val][index]+''+
'Unemployment rate: '+data.metro.unemployment[val][index]+'%'
);
},
onRegionLabelShow: function(event, label, code){
label.html(
''+label.html()+''+
'Unemployment rate: '+data.states[val][code]+'%'
);
}
});
var mapObject = $('#world-map-gdp').vectorMap('get', 'mapObject');
$("#slider").slider({
value: val,
min: 2005,
max: 2009,
step: 1,
slide: function( event, ui ) {
val = ui.value;
mapObject.series.regions[0].setValues(data.states[ui.value]);
mapObject.series.markers[0].setValues(data.metro.unemployment[ui.value]);
mapObject.series.markers[1].setValues(data.metro.population[ui.value]);
}
});
});
});
})
</script>
</head>
<body>
<div class="map" style="width: 800px; height: 600px"></div>
<div class="slider" style="width: 280px; margin: 10px"></div>
</body>
</html>