From e86f2cd935638ec015b2f45972fdf5f4c5cd00ae Mon Sep 17 00:00:00 2001 From: Trdat Mkrtchyan Date: Wed, 24 Jan 2024 19:53:00 +0400 Subject: [PATCH] fix: fixed fully redrawing updates in .setSeries (#205) --- src/YagrCore/mixins/dynamic-updates.ts | 42 ++++++-------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/src/YagrCore/mixins/dynamic-updates.ts b/src/YagrCore/mixins/dynamic-updates.ts index 874c4da..910caed 100644 --- a/src/YagrCore/mixins/dynamic-updates.ts +++ b/src/YagrCore/mixins/dynamic-updates.ts @@ -375,42 +375,20 @@ function setSeriesImpl( this.config.timeline.splice(0, timeline.length); } } else { - /** If we're adding new series or removing */ - if ( - series.length !== this.config.series.length || - series.some(({id, type}) => { - /** @TODO fixme (see Annotations.1) */ - return type === 'dots' || this.config.series.find((s) => s.id !== id); - }) || - this.config.chart.series?.type === 'dots' - ) { - batch.reinit = true; - } - - this.config.series = series; this.config.timeline = timeline; - batch.fns.push(() => { - series.forEach((s, idx) => { - const uSeries = this.getSeriesById(s.id!); - if (!uSeries) { - return; - } - - overrideSeriesInUpdate(uSeries, configureSeries(this, s, idx)); - }); - this.plugins.cursor?.updatePoints(); - }); - batch.reopt = true; - shouldRecalcData = true; + this.config.series = series; + batch.reinit = true; } - this._batch.fns.push(() => this.plugins?.tooltip?.reset()); + if (!batch.reinit) { + this._batch.fns.push(() => this.plugins?.tooltip?.reset()); - if (shouldRecalcData || timeline.length) { - batch.recalc = true; - batch.fns.push(() => { - this.uplot.setData(this.series); - }); + if (shouldRecalcData || timeline.length) { + batch.recalc = true; + batch.fns.push(() => { + this.uplot.setData(this.series); + }); + } } }