From 0a58aad22009256683cf03adc71879500c5867e8 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 31 Dec 2017 17:39:39 +0100 Subject: [PATCH] Add full name to tooltip --- js/diagrams.js | 2 +- js/util.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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