Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

341
Views
chart js line chart with iso date

No matter what I change in options, my chart labels never change.

My example data and the function:

aggs_date = {
  '2022-01-20T08:00:00.000Z': 31,
  '2022-01-20T09:00:00.000Z': 157,
  '2022-01-20T10:00:00.000Z': 171,
  '2022-01-20T11:00:00.000Z': 153,
  '2022-01-20T12:00:00.000Z': 175,
  '2022-01-20T13:00:00.000Z': 169,
  '2022-01-20T14:00:00.000Z': 186,
}

 var lineChart = new Chart(lineChartctx, {
            type: 'line',
            data: {
                labels: Object.keys(aggs_date),
                datasets: [{
                    label: 'News over Time',
                    data: Object.values(aggs_date),
                    fill: false,
                    borderColor: 'rgb(75, 192, 192)',
                }],
            },
            options: {
                scales: {
                    xAxes: [{
                        type: 'time',
                        time: {
                            displayFormats: {
                                unit: 'day',
                        }
                        }
                    }]
                }
            }
        });

I have tried a lot in the xAxes options but nothing changes. My browser console also always gives me Invalid scale configuration for scale: xAxes.

for example this, because sometimes there are too many labels.

time: {
    autoSkip: true,
    maxTicksLimit: 10
}

Is it possible that chart js doesn't recognize the isodate format? Do I need to format the date beforehand? I thought chart js should be able to recognize a iso date.

My Chart with iso date

I want to be able to limit the number of labels on the xaxes and also be able to format the output to for example only show the Date in YYYY-MM-DD format or YYYY-MM-DD HH::mm, depending if a time is available.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!