Hey.
In order to properly format the data for Y-axis, I transform a copy of every data.Time into a new Date object and map it through an Array.
const racingTime= data.map((cyclist)=>
{
let trackTime=cyclist.Time.split(':');
return new Date(Date.UTC(cyclist.Year,1,1,0,trackTime[0],trackTime[1]));
});
Of course, for tick format, I use the d3.timeFormat() method:
let minutesFormat=d3.timeFormat("%M:%S");
Followed by creating the Y-axis:
//Scale Y axis
const yScale= d3.scaleTime()
.domain(d3.extent(racingTime,(d)=> d))
.range([h-padding,padding]);
// Y axis
const yAxis = d3.axisLeft(yScale)
.tickFormat(minutesFormat);
svg.append("g")
.attr("id","y-axis")
.attr("transform", "translate("+(padding+10) + ",0)")
.call(yAxis);
However, the outcome only displays “00:00” on every tick value from the axis. I can’t tell why is that.
My code on codepen is: https://codepen.io/Sharkantropo/full/YgVygX Thanks in advance.