Added Tick Data for Y-Axis
This commit is contained in:
parent
e7a6131bfb
commit
4eb25265c2
@ -98,9 +98,24 @@ function createLineGraph(containerId, raceData){
|
|||||||
|
|
||||||
// Add the Y Axis on both sides
|
// Add the Y Axis on both sides
|
||||||
svg.append("g")
|
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")
|
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 )");
|
.attr("transform", "translate( " + (width) + ", 0 )");
|
||||||
|
|
||||||
function handleClickOnPoint(d,i){
|
function handleClickOnPoint(d,i){
|
||||||
@ -208,4 +223,21 @@ function createLineGraph(containerId, raceData){
|
|||||||
return lapTextArr;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ function getDriverCodeAndPositionArray(raceData, lapNumber){
|
|||||||
return posDriverCode;
|
return posDriverCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDriverCodeById(raceData,driverId){
|
function getDriverCodeById(raceData, driverId){
|
||||||
return raceData.drivers.filter(driv=> driv.driverId == driverId)[0].code;
|
return raceData.drivers.filter(driv => driv.driverId == driverId)[0].code;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeDuplicates(result,obj){
|
function removeDuplicates(result,obj){
|
||||||
|
Loading…
Reference in New Issue
Block a user