Chartjs-Why is my ChartJs grid not matching up with points?

0πŸ‘

βœ…

I assume the issue is, that your localtime has a date offset off -1 hours, but without seeing the data (and knowing the offset), I can’t say for sure.

If this would be the case, you could/would have to convert your dataset values. Depending on your dataset and available libraries you could use functions like:

  • momentjs:

    let localDate= moment.utc("2023-02-01 10:00:00")
        .local()
        .format("YYYY-MM-DD HH:mm:ss");
    
  • vanilajs:

    let localDate = new Date(Date.UTC(2023, 1, 1, 10, 0, 0));
    

You would have to loop through all the x-values / dates entries, to fix this.

Leave a comment