Merge branch 'master' of github.com:F1Vis/f1vis

This commit is contained in:
Jan Philipp Timme 2017-12-08 12:54:01 +01:00
commit 08f830d60a
1 changed files with 47 additions and 10 deletions

View File

@ -38,21 +38,58 @@ var queries = {
return dataset; return dataset;
}, },
/* getDriverById: function(driverId) {
* TODO
*/
getLapDataByRaceID: function(raceid) {
var rawData = preprocessor.getResults(); var rawData = preprocessor.getResults();
var raceID = raceid;
var lapTimes = rawData['lapTimes'].filter((val) => {return val['raceId'] == raceID;}); var result = null;
var groupedLapTimes = {};
var tempList = rawData.drivers.filter((cur) => (cur.driverId == driverId));
if(tempList.length > 0){
result = tempList[0];
}
// Return d3 dataset
return result;
},
getDriversByRaceId: function(raceId) {
var rawData = preprocessor.getResults();
var tempList = rawData.results.filter((cur) => (cur.raceId == raceId));
var result = tempList.map((cur) => queries.getDriverById(cur.driverId));
// Return d3 dataset
return result;
},
getLapDataByRaceId: function(raceId) {
var rawData = preprocessor.getResults();
var lapTimes = rawData['lapTimes'].filter((val) => val['raceId'] == raceId);
var myMap = new Map();
lapTimes.forEach(function(d,i) { lapTimes.forEach(function(d,i) {
var lapNum = d["lap"]; var lapNum = d["lap"];
var driverId = d["driverId"]; var driverId = d["driverId"];
if(groupedLapTimes[lapNum] === undefined) groupedLapTimes[lapNum] = {}; if(!myMap.has(lapNum)){
groupedLapTimes[lapNum][driverId] = d["milliseconds"]; var data = [];
myMap.set(lapNum,data);
}
var dt = myMap.get(lapNum);
dt.push(d);
myMap.set(lapNum,dt);
}); });
return groupedLapTimes;
myMap.forEach((d,i) => d.sort((o1,o2) => o1["position"] - o2["position"]));
return myMap;
},
getQualifingDataByRaceId: function(raceId) {
var rawData = preprocessor.getResults();
var result = rawData.qualifying.filter((cur) => (cur.raceId == raceId));
result.sort((o1,o2) => o1["position"] - o2["position"]);
return result;
} }
}; };