From 9dce5cf5a86832545fd157fcdc4c36757aa19eb2 Mon Sep 17 00:00:00 2001 From: Arjun Choudhary Date: Mon, 28 Nov 2022 15:56:38 +0530 Subject: [PATCH] chore: clone in update --- src/js/charts/BaseChart.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/js/charts/BaseChart.js b/src/js/charts/BaseChart.js index adb37ef1..5a63c7d5 100644 --- a/src/js/charts/BaseChart.js +++ b/src/js/charts/BaseChart.js @@ -184,11 +184,13 @@ export default class BaseChart { if (init) { this.data = this.realData; setTimeout(() => { - this.update(this.data); + this.update(this.data, true); }, this.initTimeout); } - this.renderLegend(); + if (this.config.showLegend) { + this.renderLegend(); + } this.setupNavigation(init); } @@ -264,14 +266,12 @@ export default class BaseChart { this.components = new Map(); } - update(data) { - if (!data) { - console.error("No data to update."); - } + update(data, drawing = false) { + if (!data) console.error("No data to update."); + if (!drawing) data = deepClone(data); this.data = this.prepareData(data); this.calc(); // builds state this.render(this.components, this.config.animate); - this.renderLegend(); } render(components = this.components, animate = true) {