Skip to content

Commit

Permalink
fix: fixed setConfig config update (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
zefirka authored Jul 4, 2023
1 parent b07eb94 commit 0c43ac1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
14 changes: 13 additions & 1 deletion demo/examples/hooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,20 @@ <h1>Hooks</h1>
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'},
],
});
Expand Down
4 changes: 3 additions & 1 deletion src/YagrCore/mixins/create-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export class CreateUplotOptionsMixin<T extends MinimalValidConfig> {
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);
Expand Down
5 changes: 1 addition & 4 deletions src/YagrCore/mixins/dynamic-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ function setConfigImpl(yagr: Yagr, batch: Batch, newConfig: Partial<YagrConfig>)
}

batch.reopt = true;

batch.fns.push(() => {
yagr.config = {...yagr.config, ...newConfig};
});
yagr.config = {...yagr.config, ...newConfig};
}

function setSeriesImpl(
Expand Down
5 changes: 1 addition & 4 deletions src/YagrCore/utils/scales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0c43ac1

Please sign in to comment.