Signature from the previous setOption call.
Pass null on first render. Use the signature from the previous
MergePlan return value on subsequent calls.
The new ECharts option to apply.
An MergePlan with the merge strategy and normalised option.
let lastSignature: OptionSignature | null = null;
createEffect(on([instance, option], ([chart, currentOption]) => {
if (!chart || chart.isDisposed()) return;
const plan = planUpdate(lastSignature, currentOption);
lastSignature = plan.signature;
chart.setOption(plan.option, {
notMerge: plan.notMerge,
replaceMerge: plan.replaceMerge.length > 0 ? plan.replaceMerge : undefined,
});
}));
Produces the minimal correct
setOptionmerge strategy by diffing the previous option signature against the new option.Decision logic (in priority order):
notMerge: falseoptionsarray shrank (timeline steps removed) ->notMerge: truemediaarray shrank (responsive breakpoints removed) ->notMerge: truenotMerge: true(ECharts merge cannot reliably remove missing top-level components/settings)replaceMerge: [key](targeted replacement removes the stale items without resetting everything)notMerge: false(standard merge, no removals detected)