diff --git a/js/diagrams.js b/js/diagrams.js index 1e3d222..6df2d6a 100644 --- a/js/diagrams.js +++ b/js/diagrams.js @@ -461,7 +461,7 @@ function createLineGraph(containerId, raceData){ } function getLapTextArray(raceData, d){ - var driverText = getDriverCodeById(raceData,d.driverId); + var driverText = getDriverCodeById(raceData,d.driverId) + " - " + getDriverNameById(raceData,d.driverId); var lapText = "Lap: " + d.lap; var posText = "Pos: " + d.position; var returnArr = [driverText, lapText, posText]; diff --git a/js/util.js b/js/util.js index e55fd83..aa20cbc 100644 --- a/js/util.js +++ b/js/util.js @@ -85,6 +85,12 @@ function getDriverCodeAndPositionArray(raceData, lapNumber){ return posDriverCode; } +function getDriverNameById(raceData, driverId){ + var driverData = raceData.drivers.filter(driv => driv.driverId == driverId)[0]; + if(driverData === undefined) return "XXX"; // TODO: Do a real fix instead of this quick fix + return driverData.forename + " " + driverData.surname; +} + function getDriverCodeById(raceData, driverId){ var driverData = raceData.drivers.filter(driv => driv.driverId == driverId)[0]; if(driverData === undefined) return "XXX"; // TODO: Do a real fix instead of this quick fix