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

176
Views
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 answers
Answer question

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 Report
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!