From 51f966f640e70ee9f85b2460bfa0246bfce58e3e Mon Sep 17 00:00:00 2001 From: Trdat Mkrtchyan Date: Tue, 4 Jul 2023 15:09:08 +0400 Subject: [PATCH] fix: fixed setConfig config update --- demo/examples/hooks.html | 14 +++++++++++++- src/YagrCore/mixins/create-options.ts | 4 +++- src/YagrCore/mixins/dynamic-updates.ts | 5 +---- src/YagrCore/utils/scales.ts | 5 +---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/demo/examples/hooks.html b/demo/examples/hooks.html index ce7470b..c5b11fe 100644 --- a/demo/examples/hooks.html +++ b/demo/examples/hooks.html @@ -140,8 +140,20 @@

Hooks

max: 15, }, }, + processing: { + interpolation: { + value: 'x', + type: 'left', + }, + }, series: [ - {data: new Array(20).fill().map((_, i) => Math.random() * 6), color: 'red', id: '1'}, + { + data: new Array(20) + .fill() + .map((_, i) => (Math.random() * 6 > 2 ? 'x' : Math.random() * 6)), + color: 'red', + id: '1', + }, {data: new Array(20).fill().map((_, i) => Math.random() * 6), color: 'orange', id: '2'}, ], }); diff --git a/src/YagrCore/mixins/create-options.ts b/src/YagrCore/mixins/create-options.ts index 41fa13a..410c53f 100644 --- a/src/YagrCore/mixins/create-options.ts +++ b/src/YagrCore/mixins/create-options.ts @@ -45,7 +45,9 @@ export class CreateUplotOptionsMixin { this.plugins.tooltip = tooltipInstance; } - if (!reOpt) { + if (reOpt) { + this.plugins.plotLines && plugins.push(this.plugins.plotLines.uplot); + } else { const plotLinesPluginInstance = this.initPlotLinesPlugin(config); this.plugins.plotLines = plotLinesPluginInstance; plugins.push(plotLinesPluginInstance.uplot); diff --git a/src/YagrCore/mixins/dynamic-updates.ts b/src/YagrCore/mixins/dynamic-updates.ts index 5d258a0..62fb4a3 100644 --- a/src/YagrCore/mixins/dynamic-updates.ts +++ b/src/YagrCore/mixins/dynamic-updates.ts @@ -232,10 +232,7 @@ function setConfigImpl(yagr: Yagr, batch: Batch, newConfig: Partial) } batch.reopt = true; - - batch.fns.push(() => { - yagr.config = {...yagr.config, ...newConfig}; - }); + yagr.config = {...yagr.config, ...newConfig}; } function setSeriesImpl( diff --git a/src/YagrCore/utils/scales.ts b/src/YagrCore/utils/scales.ts index 8396e02..76887a0 100644 --- a/src/YagrCore/utils/scales.ts +++ b/src/YagrCore/utils/scales.ts @@ -196,10 +196,7 @@ export function configureScales(yagr: Yagr, scales: UPlot.Scales, config: YagrCo } if (yagr.isEmpty) { - scale.range = [ - forceMin === null ? (isLogScale ? 1 : 0) : forceMin, // eslint-disable-line no-nested-ternary - forceMax === null ? 100 : forceMax, - ]; + scale.range = [forceMin === null ? (isLogScale ? 1 : 0) : forceMin, forceMax === null ? 100 : forceMax]; return; }