diff --git a/src/YagrCore/mixins/dynamic-updates.ts b/src/YagrCore/mixins/dynamic-updates.ts index 074f9c3..785e17f 100644 --- a/src/YagrCore/mixins/dynamic-updates.ts +++ b/src/YagrCore/mixins/dynamic-updates.ts @@ -194,7 +194,13 @@ function areSeriesChanged(a: YagrConfig['series'], b?: YagrConfig['series']) { return false; } -function setConfigImpl(yagr: Yagr, batch: Batch, newConfig: Partial) { +function setConfigImpl(yagr: Yagr, batch: Batch, newConfig: Partial, fullUpdate = false) { + if (fullUpdate) { + yagr.config = {...yagr.config, ...newConfig}; + batch.reinit = true; + return; + } + const isChangedKey = isChanged(yagr.config, newConfig); if (newConfig.title && isChangedKey('title')) { @@ -515,8 +521,8 @@ export class DynamicUpdatesMixin { * @param newConfig Partial * @descriptino Sets new config and redraws. */ - setConfig(this: Yagr, newConfig: Partial) { - this.batch((batch) => setConfigImpl(this, batch, newConfig)); + setConfig(this: Yagr, newConfig: Partial, fullUpdate = false) { + this.batch((batch) => setConfigImpl(this, batch, newConfig, fullUpdate)); } } diff --git a/src/react.tsx b/src/react.tsx index 7733191..80df06a 100644 --- a/src/react.tsx +++ b/src/react.tsx @@ -11,6 +11,8 @@ export interface YagrChartProps { config: MinimalValidConfig; /** Root component class name */ className?: string; + /** Update strategy */ + update?: 'dynamic' | 'hard'; /** Debug data */ debug?: { filename: string; @@ -29,7 +31,7 @@ export interface YagrReactRef { // eslint-disable-next-line prefer-arrow-callback export default React.forwardRef(function YagrReact( - {id, config, className = '', debug, onChartLoad, onSelect}: YagrChartProps, + {id, config, className = '', debug, onChartLoad, onSelect, update = 'dynamic'}: YagrChartProps, ref, ) { const chartRef = React.useRef(null); @@ -63,7 +65,7 @@ export default React.forwardRef(function YagrReact( }, []); React.useEffect(() => { - config && chart.current?.setConfig(config); + config && chart.current?.setConfig(config, update === 'hard'); }, [config]); React.useEffect(() => {