Added Tick Data for Y-Axis

This commit is contained in:
sirsandmann 2017-12-19 21:35:47 +01:00
parent e7a6131bfb
commit 4eb25265c2
2 changed files with 37 additions and 5 deletions

View File

@ -98,9 +98,24 @@ function createLineGraph(containerId, raceData){
// Add the Y Axis on both sides
svg.append("g")
.call(d3.axisLeft(y));
.call(
d3.axisLeft(y)
.ticks(raceData.drivers.length)
.tickFormat(function(d) {
console.log(getDriverCodeFromPosAndLap(raceData, 0, d) + " " + d);
return getDriverCodeFromPosAndLap(raceData, 0, d) + " " + d;
})
);
svg.append("g")
.call(d3.axisRight(y))
.call(
d3.axisRight(y)
.ticks(raceData.drivers.length)
.tickFormat(function(d) {
console.log(getDriverCodeFromPosAndLap(raceData, raceData.lapTimes.size, d) + " " + d);
return d + " " + getDriverCodeFromPosAndLap(raceData, raceData.lapTimes.size, d) ;
})
)
.attr("transform", "translate( " + (width) + ", 0 )");
function handleClickOnPoint(d,i){
@ -208,4 +223,21 @@ function createLineGraph(containerId, raceData){
return lapTextArr;
}
function getDriverCodeFromPosAndLap(raceData, lapNr, pos){
var driverCode = "";
if(lapNr == 0){
driverCode = getDriverCodeById(raceData, raceData.qualifying[pos - 1].driverId);
}else if(lapNr == raceData.lapTimes.size){
var resultPos = raceData.results[pos -1].position;
var resultLaps = raceData.results[pos -1].laps;
//making sure the Driver finished and drove all laps
if(resultPos && resultLaps == raceData.lapTimes.size){
driverCode = getDriverCodeById(raceData,raceData.results[pos -1].driverId);
}
}else{
//TODO hier Adden
}
return driverCode;
}
}