Fixed the text of the right Y axis
This commit is contained in:
parent
9c2ee5debd
commit
f36f976612
|
@ -322,12 +322,7 @@ function createLineGraph(containerId, raceData){
|
||||||
d3.axisRight(y)
|
d3.axisRight(y)
|
||||||
.ticks(raceData.drivers.length)
|
.ticks(raceData.drivers.length)
|
||||||
.tickFormat(function(d) {
|
.tickFormat(function(d) {
|
||||||
var driverCode = "";
|
var driverCode = getDriverCodeFromPosAndLap(raceData, raceData.lapTimes.size, d);
|
||||||
if(getDriverCodeFromPosAndLap(raceData, raceData.lapTimes.size, d)){
|
|
||||||
driverCode = getDriverCodeFromPosAndLap(raceData, raceData.lapTimes.size, d);
|
|
||||||
}else{
|
|
||||||
driverCode = getDriverCodeFromPosAndLap(raceData, raceData.lapTimes.size - 1, d);
|
|
||||||
}
|
|
||||||
return d + " " + driverCode ;
|
return d + " " + driverCode ;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -504,16 +499,36 @@ function createLineGraph(containerId, raceData){
|
||||||
var qualifying = raceData.qualifying[pos - 1];
|
var qualifying = raceData.qualifying[pos - 1];
|
||||||
if(qualifying === undefined) return "XXX"; // TODO: Do a real fix
|
if(qualifying === undefined) return "XXX"; // TODO: Do a real fix
|
||||||
driverCode = getDriverCodeById(raceData, qualifying.driverId);
|
driverCode = getDriverCodeById(raceData, qualifying.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{
|
}else{
|
||||||
if(raceData.lapTimes.get(lapNr)[pos-1]){
|
if(lapNr == raceData.lapTimes.size){ // are at the end of the graph. Only draw driver who finished
|
||||||
driverCode = getDriverCodeById(raceData, raceData.lapTimes.get(lapNr)[pos-1].driverId);
|
var found = false;
|
||||||
|
var _pos = pos-1;
|
||||||
|
var _lap = lapNr;
|
||||||
|
while(!found){
|
||||||
|
if(raceData.lapTimes.get(_lap)[_pos]){
|
||||||
|
var driverID = raceData.lapTimes.get(_lap)[_pos].driverId;
|
||||||
|
|
||||||
|
for(var key in raceData.results){
|
||||||
|
if(raceData.results[key].driverId == driverID){
|
||||||
|
console.log(raceData.results[key]);
|
||||||
|
console.log(_lap);
|
||||||
|
if(isNaN(raceData.results[key].position) || raceData.results[key].laps != _lap){
|
||||||
|
return driverCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
driverCode = getDriverCodeById(raceData, raceData.lapTimes.get(_lap)[_pos].driverId);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_lap--;
|
||||||
|
if(_lap < 0) break;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(raceData.lapTimes.get(lapNr)[pos-1]){
|
||||||
|
driverCode = getDriverCodeById(raceData, raceData.lapTimes.get(lapNr)[pos-1].driverId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return driverCode;
|
return driverCode;
|
||||||
|
@ -572,12 +587,7 @@ function createLineGraph(containerId, raceData){
|
||||||
d3.axisRight(y)
|
d3.axisRight(y)
|
||||||
.ticks(raceData.drivers.length)
|
.ticks(raceData.drivers.length)
|
||||||
.tickFormat(function(d) {
|
.tickFormat(function(d) {
|
||||||
var driverCode = "";
|
var driverCode = getDriverCodeFromPosAndLap(raceData, endLap, d);
|
||||||
if(getDriverCodeFromPosAndLap(raceData, endLap, d)){
|
|
||||||
driverCode = getDriverCodeFromPosAndLap(raceData, endLap, d);
|
|
||||||
}else{
|
|
||||||
driverCode = getDriverCodeFromPosAndLap(raceData, endLap - 1, d); // TODO: only if the driver has finished..
|
|
||||||
}
|
|
||||||
return d + " " + driverCode ;
|
return d + " " + driverCode ;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue