Chartjs-How to parse time 'HH:MM:SS' and display steps on xAxis every minute in Chart.js

0👍

Ok here you go, takes the 2 arguments specified in the comments, and assumes a reasonable version of JS is running.

function getTicks(startTime, count) {
    let ticks = [],
        date = startTime;
    for (let x = 0; x < count; x++) {
        let hours = date.getHours().toString(),
            mins = date.getMinutes().toString(),
            seconds = date.getSeconds().toString();

        date = new Date(date.getTime() + 60000);
        ticks.push(`${hours.padStart(2, '0')}:${mins.padStart(2, '0')}:${seconds.padStart(2, '0')}`);
    }

    return ticks;
}

Leave a comment