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

181
Visualizações
How to update Chartjs chart (react-chartjs-2) with dynamic data?

I've been trying to make a simple chart generator in React. I use Handsontable to let the user enter dynamic data and I would like the changes to be reflected in the chart. Here is my code: Codesandbox reproducible.

Small disclaimer: the handsontable package is pretty buggy in codesandbox. Just double click a number and an inputfield will appear where you can edit data.

The problem

For some reason, you can only edit something from the first data row and the second data row (labels not included). After that, the chart won't update anymore. So try changing 11 under the Mercedes label and you will see what I mean. Those can be changed and the changes will be reflected in the chart, but any number changed after that won't update the chart.

Now I've read this github issue where people suggest to add a random key (key={Math.random()}) or the redraw prop, and that somewhat works, but the whole chart gets redrawn, which is not exactly what I want.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The problem was with mutating deep nested properties. I've used lodash clonedeep to deepclone the object. Then changing the contents of that object and setting the state. It all worked fine after that.

I updated the codesandbox reproduction in case someone needs it.

about 4 years ago · Juan Pablo Isaza Relatório
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