From bc09c1eb17d12ce307e409a965f70ece110934dd Mon Sep 17 00:00:00 2001 From: sirsandmann Date: Fri, 29 Dec 2017 17:12:01 +0100 Subject: [PATCH] Fixed undefined time texts --- js/diagrams.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/diagrams.js b/js/diagrams.js index eb0b00e..b322f4e 100644 --- a/js/diagrams.js +++ b/js/diagrams.js @@ -97,6 +97,7 @@ function createLineGraph(containerId, raceData){ .attr("data-line", driverLapData.driver.driverId) .attr("data-opacitychange", 0) .attr("data-highlighted", 0) + .attr("data-elemtype", elemTypes.linepoint) .attr("fill", getColorValue(driverIndex, enhancedLapData.length)) .attr("cx", function(d, i) {return x(d.lap) }) .attr("cy", function(d, i) { return y(d.position) }) @@ -234,7 +235,7 @@ function createLineGraph(containerId, raceData){ var textArr = []; var circleId = "circle-linepoint-" + d.lap + "-" + d.driverId; var circle = d3.select("#" + circleId); - + // Add interactivity // Use D3 to select element, change color and size if(dataType === elemTypes.linepoint){ @@ -299,11 +300,18 @@ function createLineGraph(containerId, raceData){ } function getLapTextArray(raceData, d){ + var driverText = getDriverCodeById(raceData,d.driverId); var lapText = "Lap: " + d.lap; var posText = "Pos: " + d.position; - var timeText = "Time: " + d.time; - return [driverText, lapText, posText, timeText]; + + var returnArr = [driverText, lapText, posText]; + if(d.time){ + var timeText = "Time: " + d.time; + returnArr.push(timeText); + } + + return returnArr; } function getPitStopTextArray(raceData, d){