question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replacing entire data object by cloned one, causes error.

See original GitHub issue

Same setup as https://github.com/chartjs/Chart.js/issues/3614 but instead of replacing data object for new one, I am replacing for deep cloned one, and it causes error.

      var clonedData = _.cloneDeep(myLine.config.data);
      myLine.config.data.datasets = clonedData.datasets;
      myLine.update();

causes error:

Chart.min.js:12 Uncaught TypeError: Cannot read property 'datasets' of undefined
    at a.getDataset (Chart.min.js:12)
    at a.buildOrUpdateElements (Chart.min.js:12)
    at t.Controller.<anonymous> (Chart.min.js:11)
    at Object.o.each (Chart.min.js:12)
    at t.Controller.update (Chart.min.js:11)
    at HTMLButtonElement.<anonymous> ((index):184)

Here it is reproduced in fiddle https://jsfiddle.net/935heqas/, just RUN the code and click on the “REPLACE ENTIRE DATA OBJECT” button.

It seems to be some reference mismatch problem inside chartjs.

Many thanks for any help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
alex2wongcommented, Aug 20, 2018

I suppose you can try a feature request to the core maintainer, to make chart.data props immutable. @benmccann

0reactions
etimbergcommented, Feb 22, 2021

This appears to work fine in v3.0.0-beta.11 https://jsfiddle.net/ecw1q2of/

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix cloning error while cloning an object - Stack Overflow
You should follow 2 rules. 1. implements Cloneable Interface 2. clone returns an Object. You have to cast.
Read more >
Cloning Considerations - Snowflake Documentation
This topic provides important considerations when cloning objects in Snowflake, particularly databases, schemas, and non-temporary tables.
Read more >
Methods for deep cloning objects in JavaScript - LogRocket Blog
There are several ways to shallow clone objects in JavaScript, but deep cloning objects is trickier. We highlight several methods to do so....
Read more >
Response.clone() - Web APIs - MDN Web Docs
If only one cloned branch is consumed, then the entire body will be ... main reason clone() exists is to allow multiple uses...
Read more >
MySQL 8.0 Reference Manual :: 5.6.7.3 Cloning Remote Data
This error does not indicate a cloning failure. It means that the recipient MySQL server instance must be started again manually after the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found