diff --git a/src/hooks/useEcharts.ts b/src/hooks/useEcharts.ts index 7e661d9c..052b751e 100644 --- a/src/hooks/useEcharts.ts +++ b/src/hooks/useEcharts.ts @@ -14,12 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { BarSeriesOption, LineSeriesOption } from "echarts/charts"; +import { + BarSeriesOption, + LineSeriesOption, + HeatmapSeriesOption, + PieSeriesOption, +} from "echarts/charts"; import { TitleComponentOption, TooltipComponentOption, GridComponentOption, DatasetComponentOption, + LegendComponentOption, } from "echarts/components"; import type { Ref } from "vue"; import { useTimeoutFn } from "./useTimeout"; @@ -37,6 +43,9 @@ export type ECOption = echarts.ComposeOption< | TooltipComponentOption | GridComponentOption | DatasetComponentOption + | LegendComponentOption + | HeatmapSeriesOption + | PieSeriesOption >; export function useECharts( @@ -46,7 +55,7 @@ export function useECharts( const getDarkMode = computed(() => { return theme === "default" ? "light" : theme; }); - let chartInstance: echarts.ECharts | null = null; + let chartInstance: Nullable = null; let resizeFn: Fn = resize; const cacheOptions = ref({}) as Ref; let removeResizeFn: Fn = () => ({}); @@ -128,7 +137,7 @@ export function useECharts( chartInstance = null; }); - function getInstance(): echarts.ECharts | null { + function getInstance(): Nullable { if (!chartInstance) { initCharts(getDarkMode.value as "default"); } diff --git a/src/utils/is.ts b/src/utils/is.ts index e55b1925..edf4ef36 100644 --- a/src/utils/is.ts +++ b/src/utils/is.ts @@ -32,22 +32,6 @@ export function isObject(val: unknown): val is Record { return val !== null && is(val, "Object"); } -export function isEmpty(val: any): val is T { - if (isArray(val) || isString(val)) { - return val.length === 0; - } - - if (val instanceof Map || val instanceof Set) { - return val.size === 0; - } - - if (isObject(val)) { - return Object.keys(val).length === 0; - } - - return false; -} - export function isDate(val: unknown): val is Date { return is(val, "Date"); } @@ -81,7 +65,7 @@ export function isString(val: unknown): val is string { return is(val, "String"); } -export function isFunction(val: unknown): boolean { +export function isFunction(val: unknown): val is () => unknown { return typeof val === "function"; } @@ -93,8 +77,8 @@ export function isRegExp(val: unknown): val is RegExp { return is(val, "RegExp"); } -export function isArray(val: any): boolean { - return val && Array.isArray(val); +export function isArray(val: unknown): boolean { + return Array.isArray(val); } export function isWindow(val: unknown): val is Window {