-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnyctaxi.js
68 lines (57 loc) · 2.77 KB
/
nyctaxi.js
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
(function () {
var myConnector = tableau.makeConnector();
myConnector.getSchema = function (schemaCallback) {
var cols = [
{ id : "date", alias:"Date", dataType : tableau.dataTypeEnum.string },
{ id : "trips", alias: "Trips Per Day",dataType : tableau.dataTypeEnum.string },
{ id : "farebox",alias: "Farebox Per Day", dataType : tableau.dataTypeEnum.string },
{ id : "uniquemed",alias: "Unique Medallions", dataType : tableau.dataTypeEnum.string },
{ id : "uniquedrivers", alias: "Unique Drivers", dataType : tableau.dataTypeEnum.string},
{ id : "medperday", alias: "Medallions Per Day", dataType : tableau.dataTypeEnum.string },
{ id : "avg1", alias: "Average Days Medallions On Road", dataType : tableau.dataTypeEnum.string },
{ id : "avg2", alias: "Avg Hours Per Day Per Medallion", dataType : tableau.dataTypeEnum.string},
{ id : "avg3", alias:"Avg Days Drivers on Road", dataType : tableau.dataTypeEnum.string},
{ id : "avg4", alias:"Avg Hours Per Day Per Driver", dataType : tableau.dataTypeEnum.string},
{ id : "avg5", alias: "Avg Minutes Per Trip", dataType : tableau.dataTypeEnum.string},
{ id : "cc", alias: "Percent of Trips Paid with Credit Card", dataType : tableau.dataTypeEnum.string}
];
var tableInfo = {
id : "taxi",
alias : "TLC Trip Data",
columns : cols
};
schemaCallback([tableInfo]);
};
myConnector.getData = function(table, doneCallback) {
$.getJSON("https://s3.amazonaws.com/nikhilstrail/nyctaxi.json", function(resp) {
var feat = resp;
tableData = [];
// Iterate over the JSON object
for (var i = 0, len = feat.length; i < len; i++) {
tableData.push({
"date": feat[i]["Month"]["Year"],
"trips": feat[i]["Trips Per Day"],
"farebox": feat[i] ["Farebox Per Day"],
"uniquemed": feat[i] ["Unique Medallions"],
"uniquedrivers": feat[i] ["Unique Drivers"],
"medperday": feat[i] ["Medallions Per Day"],
"avg1": feat[i] ["Avg Days Medallions on Road"],
"avg2": feat[i] ["Avg Hours Per Day Per Medallion"] ,
"avg3": feat[i] ["Avg Days Drivers on Road"],
"avg4": feat[i] ["Avg Hours Per Day Per Driver"],
"avg5": feat[i] ["Avg Minutes Per Trip"],
"cc": feat[i] ["Percent of Trips Paid with Credit Card"]
});
}
table.appendRows(tableData);
doneCallback();
});
};
tableau.registerConnector(myConnector);
$(document).ready(function () {
$("#submitButton").click(function () {
tableau.connectionName = "taxi";
tableau.submit();
});
});
})();