feat(echarts): add getInstance for useECharts
为useECharts添加getInstance以便绑定事件或执行更多自定义动作
| | |
| | | |
| | | resizeFn = useDebounceFn(resize, 200); |
| | | |
| | | const getOptions = computed( |
| | | (): EChartsOption => { |
| | | if (getDarkMode.value !== 'dark') { |
| | | return cacheOptions.value; |
| | | } |
| | | return { |
| | | backgroundColor: 'transparent', |
| | | ...cacheOptions.value, |
| | | }; |
| | | const getOptions = computed((): EChartsOption => { |
| | | if (getDarkMode.value !== 'dark') { |
| | | return cacheOptions.value; |
| | | } |
| | | ); |
| | | return { |
| | | backgroundColor: 'transparent', |
| | | ...cacheOptions.value, |
| | | }; |
| | | }); |
| | | |
| | | function initCharts(t = theme) { |
| | | const el = unref(elRef); |
| | |
| | | chartInstance = null; |
| | | }); |
| | | |
| | | function getInstance(): echarts.ECharts | null { |
| | | if (!chartInstance) { |
| | | initCharts(getDarkMode.value as 'default'); |
| | | } |
| | | return chartInstance; |
| | | } |
| | | |
| | | return { |
| | | setOptions, |
| | | resize, |
| | | echarts, |
| | | getInstance, |
| | | }; |
| | | } |