Skip to content

Commit

Permalink
fix: fixed fully redrawing updates in .setSeries (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
zefirka authored Jan 24, 2024
1 parent 9d011a2 commit e86f2cd
Showing 1 changed file with 10 additions and 32 deletions.
42 changes: 10 additions & 32 deletions src/YagrCore/mixins/dynamic-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
}

Expand Down

0 comments on commit e86f2cd

Please sign in to comment.