Replacing entire data object by cloned one, causes error.
See original GitHub issueSame 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:
- Created 5 years ago
- Comments:9 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suppose you can try a feature request to the core maintainer, to make chart.data props immutable. @benmccann
This appears to work fine in v3.0.0-beta.11 https://jsfiddle.net/ecw1q2of/