feat(hooks): add setOptions for useEcharts

This commit is contained in:
Soybean 2024-05-07 19:17:20 +08:00
parent e7f0a30bd8
commit e4d53aa7b5

View File

@ -146,6 +146,10 @@ export function useEcharts<T extends ECOption>(optionsFactory: () => T, hooks: C
await onUpdated?.(chart!); await onUpdated?.(chart!);
} }
function setOptions(options: T) {
chart?.setOption(options);
}
/** render chart */ /** render chart */
async function render() { async function render() {
if (!isRendered()) { if (!isRendered()) {
@ -225,6 +229,7 @@ export function useEcharts<T extends ECOption>(optionsFactory: () => T, hooks: C
return { return {
domRef, domRef,
updateOptions updateOptions,
setOptions
}; };
} }