Chartjs-Is it possible to make ChartJS X-Axis an automatic day based on data and formatted to month?

0👍

For anyone that comes across this, I ended up figuring it out using the luxon library.

let arrayOfDates = [];

for (let i = 0; i < data.length; i++) {
    arrayOfDates.push(DateTime.local().minus({
        days: i
    }).toLocaleString({
        month: 'short',
        day: 'numeric'
    }));
}

arrayOfDates.reverse();

So what is happening here is I am creating an array of dates based on today and then subtracting a day for each point of data. I then reverse the array to match the direction of the data in the chart. I then use this array of dates as the labels.

Leave a comment