-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatamaps_us_test.html
72 lines (62 loc) · 2.84 KB
/
datamaps_us_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
<!DOCTYPE html>
<head>
<meta charset="utf-8"/>
</head>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.min.js"></script>
<script src="./datamaps.usa.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<div id="container" style="position: relative; width: 1300px; height: 750px;"></div>
<script>
var map = new Datamap({
scope: 'usa',
element: document.getElementById('container'),
data: {},
});
function changeBlah() {
data = {
resource_id: 'cdb53058-f36b-4852-97d9-4177ffd74a9e',
sql: 'SELECT SUM(CAST("DEPARTURES_SCHEDULED" AS INTEGER)) AS DEPARTURES_SCHEDULED,SUM(CAST("DEPARTURES_PERFORMED" AS INTEGER))' +
'AS DEPARTURES_PERFORMED,SUM(CAST("PASSENGERS" AS INTEGER)) AS PASSENGERS,SUM(CAST("FREIGHT" AS INTEGER)) AS FREIGHT,' +
'SUM(CAST("MAIL" AS INTEGER)) AS MAIL, "YEAR", "ORIGIN_STATE_ABR", "ORIGIN_STATE_NM","ORIGIN_COUNTRY", "ORIGIN_COUNTRY_NAME",' +
'"DEST_STATE_ABR", "DEST_STATE_NM", "DEST_COUNTRY", "DEST_COUNTRY_NAME" FROM "cdb53058-f36b-4852-97d9-4177ffd74a9e"' +
'WHERE "YEAR" LIKE \'1990\' AND "ORIGIN_STATE_ABR" LIKE \'PR\' AND "DEST_COUNTRY" NOT LIKE \'US\' GROUP BY "YEAR",' +
'"ORIGIN_STATE_ABR", "ORIGIN_STATE_NM", "ORIGIN_COUNTRY", "ORIGIN_COUNTRY_NAME", "DEST_STATE_ABR","DEST_STATE_NM",' +
'"DEST_COUNTRY", "DEST_COUNTRY_NAME";'
};
$.ajax({
url: 'https://datos.estadisticas.pr/api/action/datastore_search_sql',
data: data,
dataType: 'jsonp',
success: function(data) {
<!-- alert('Total results found: ' + data.result.records.length)-->
console.log(data.result.records)
var arcs = []
for(var i=0;i < data.result.records.length;i++) {
arcs[i] = {origin: data.result.records[i].ORIGIN_STATE_ABR, destination: data.result.records[i].DEST_COUNTRY}
}
map.arc([
{
origin: "TX",
destination: "CA"
}
]);
<!-- map.arc(arcs);-->
console.log(arcs)
<!-- map.updateChoropleth();-->
}
});
}
</script>
<fieldset>
<legend>Configuration Options:</legend>
<span>Select year to filter by: </span><input type="number" min="1990" max="2021" step="1" required="required" placeholder="1990 - 2021"/>
<br><br>
<input type="radio" id="incoming" name="flight_type" value="Incoming">
<label for="incoming">Incoming Flights to PR</label><br>
<input type="radio" id="outgoing" name="flight_type" value="Outgoing">
<label for="outgoing">Outgoing Flights from PR</label><br>
<br><br>
<button type="button" onclick="changeBlah()">Get Flights Info</button>
</fieldset>
</html>