fix: clone in update
This commit is contained in:
parent
ba0d3703f5
commit
a0265677a2
@ -13,7 +13,7 @@ import { deepClone } from '../utils/helpers';
|
|||||||
|
|
||||||
export default class BaseChart {
|
export default class BaseChart {
|
||||||
constructor(parent, options) {
|
constructor(parent, options) {
|
||||||
options = deepClone(options)
|
options = deepClone(options);
|
||||||
|
|
||||||
this.parent = typeof parent === 'string'
|
this.parent = typeof parent === 'string'
|
||||||
? document.querySelector(parent)
|
? document.querySelector(parent)
|
||||||
@ -155,7 +155,7 @@ export default class BaseChart {
|
|||||||
|
|
||||||
if (init) {
|
if (init) {
|
||||||
this.data = this.realData;
|
this.data = this.realData;
|
||||||
setTimeout(() => { this.update(this.data); }, this.initTimeout);
|
setTimeout(() => { this.update(this.data, true); }, this.initTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.showLegend) {
|
if (this.config.showLegend) {
|
||||||
@ -230,10 +230,9 @@ export default class BaseChart {
|
|||||||
|
|
||||||
setupComponents() { this.components = new Map(); }
|
setupComponents() { this.components = new Map(); }
|
||||||
|
|
||||||
update(data) {
|
update(data, drawing = false) {
|
||||||
if (!data) {
|
if (!data) console.error('No data to update.');
|
||||||
console.error('No data to update.');
|
if (!drawing) data = deepClone(data);
|
||||||
}
|
|
||||||
this.data = this.prepareData(data);
|
this.data = this.prepareData(data);
|
||||||
this.calc(); // builds state
|
this.calc(); // builds state
|
||||||
this.render(this.components, this.config.animate);
|
this.render(this.components, this.config.animate);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user