Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

348
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda