|
|
@ -1,13 +1,11 @@ |
|
|
import type { EChartsOption } from 'echarts'; |
|
|
import type { EChartsOption } from 'echarts'; |
|
|
import type { Ref } from 'vue'; |
|
|
import type { Ref } from 'vue'; |
|
|
|
|
|
|
|
|
import { useTimeoutFn } from '/@/hooks/core/useTimeout'; |
|
|
import { useTimeoutFn } from '/@/hooks/core/useTimeout'; |
|
|
import { tryOnUnmounted } from '@vueuse/core'; |
|
|
import { tryOnUnmounted } from '@vueuse/core'; |
|
|
import { unref, nextTick, watch, computed, ref } from 'vue'; |
|
|
import { unref, nextTick, watch, computed, ref } from 'vue'; |
|
|
import { useDebounceFn } from '@vueuse/core'; |
|
|
import { useDebounceFn } from '@vueuse/core'; |
|
|
import { useEventListener } from '/@/hooks/event/useEventListener'; |
|
|
import { useEventListener } from '/@/hooks/event/useEventListener'; |
|
|
import { useBreakpoint } from '/@/hooks/event/useBreakpoint'; |
|
|
import { useBreakpoint } from '/@/hooks/event/useBreakpoint'; |
|
|
|
|
|
|
|
|
import echarts from '/@/utils/lib/echarts'; |
|
|
import echarts from '/@/utils/lib/echarts'; |
|
|
import { useRootSetting } from '/@/hooks/setting/useRootSetting'; |
|
|
import { useRootSetting } from '/@/hooks/setting/useRootSetting'; |
|
|
|
|
|
|
|
|
@ -18,19 +16,19 @@ export function useECharts( |
|
|
const { getDarkMode } = useRootSetting(); |
|
|
const { getDarkMode } = useRootSetting(); |
|
|
let chartInstance: echarts.ECharts | null = null; |
|
|
let chartInstance: echarts.ECharts | null = null; |
|
|
let resizeFn: Fn = resize; |
|
|
let resizeFn: Fn = resize; |
|
|
const cacheOptions = ref<EChartsOption>({}); |
|
|
const cacheOptions = ref({}) as Ref<EChartsOption>; |
|
|
let removeResizeFn: Fn = () => {}; |
|
|
let removeResizeFn: Fn = () => {}; |
|
|
|
|
|
|
|
|
resizeFn = useDebounceFn(resize, 200); |
|
|
resizeFn = useDebounceFn(resize, 200); |
|
|
|
|
|
|
|
|
const getOptions = computed((): EChartsOption => { |
|
|
const getOptions = computed(() => { |
|
|
if (getDarkMode.value !== 'dark') { |
|
|
if (getDarkMode.value !== 'dark') { |
|
|
return cacheOptions.value; |
|
|
return cacheOptions.value as EChartsOption; |
|
|
} |
|
|
} |
|
|
return { |
|
|
return { |
|
|
backgroundColor: 'transparent', |
|
|
backgroundColor: 'transparent', |
|
|
...cacheOptions.value, |
|
|
...cacheOptions.value, |
|
|
}; |
|
|
} as EChartsOption; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function initCharts(t = theme) { |
|
|
function initCharts(t = theme) { |
|
|
|