Merge branch 'master' of https://github.com/F1Vis/f1vis
This commit is contained in:
commit
0c6e65a053
|
@ -508,6 +508,7 @@ function createLineGraph(containerId, raceData){
|
|||
var t = d3.event.transform;
|
||||
x.domain(t.rescaleX(x2).domain());
|
||||
updateElements();
|
||||
|
||||
//call the brush function
|
||||
context.select(".brush").call(brush.move, x.range().map(t.invertX, t));
|
||||
}
|
||||
|
@ -521,14 +522,26 @@ function createLineGraph(containerId, raceData){
|
|||
// Update xAxis
|
||||
focus.select(".axis--x").call(xAxis);
|
||||
|
||||
updateYAxisText();
|
||||
|
||||
// Update gridlines
|
||||
focus.select(".xAxisGridlines").call(xAxisGridlines);
|
||||
}
|
||||
|
||||
function updateYAxisText(){
|
||||
console.log("lol");
|
||||
var xAxisValues = d3.extent(x.domain());
|
||||
if(xAxisValues[1] > 1){
|
||||
// Get the min/max lap.
|
||||
var startLap = Math.floor(xAxisValues[0]);
|
||||
var endLap = Math.floor(xAxisValues[1]);
|
||||
|
||||
// Redraw the left Y axis
|
||||
focus.select(".axis--y-left").call(d3.axisLeft(y).ticks(raceData.drivers.length).tickFormat(function(d) {
|
||||
return getDriverCodeFromPosAndLap(raceData, startLap, d) + " " + d;
|
||||
}));
|
||||
|
||||
// Redraw the right Y axis
|
||||
focus.select(".axis--y-right").call(
|
||||
d3.axisRight(y)
|
||||
.ticks(raceData.drivers.length)
|
||||
|
@ -537,13 +550,11 @@ function createLineGraph(containerId, raceData){
|
|||
if(getDriverCodeFromPosAndLap(raceData, endLap, d)){
|
||||
driverCode = getDriverCodeFromPosAndLap(raceData, endLap, d);
|
||||
}else{
|
||||
driverCode = getDriverCodeFromPosAndLap(raceData, endLap - 1, d); // only if the driver has finished..
|
||||
driverCode = getDriverCodeFromPosAndLap(raceData, endLap - 1, d); // TODO: only if the driver has finished..
|
||||
}
|
||||
return d + " " + driverCode ;
|
||||
}));
|
||||
}
|
||||
// Update gridlines
|
||||
focus.select(".xAxisGridlines").call(xAxisGridlines);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue