Files
orion-visor/orion-visor-ui/src/hooks/chart-option.ts

36 lines
823 B
TypeScript
Raw Normal View History

2023-10-25 10:26:14 +08:00
import type { EChartsOption } from 'echarts';
2023-07-24 10:05:07 +08:00
import { computed } from 'vue';
2024-12-27 11:19:52 +08:00
import useThemes from '@/hooks/themes';
// 配置生成
interface OptionsFn {
(isDark: boolean, themeTextColor: string, themeLineColor: string): EChartsOption;
2023-07-24 10:05:07 +08:00
}
2024-12-27 11:19:52 +08:00
// 亮色文本色
const lightTextColor = '#4E5969';
// 暗色文本色
const darkTextColor = 'rgba(255, 255, 255, 0.7)';
// 亮色线色
const lightLineColor = '#F2F3F5';
// 暗色线色
const darkLineColor = '#2E2E30';
export default function useChartOption(sourceOption: OptionsFn) {
const { isDark } = useThemes();
// 配置
2023-07-24 10:05:07 +08:00
const chartOption = computed<EChartsOption>(() => {
2024-12-27 11:19:52 +08:00
return sourceOption(isDark.value,
isDark.value ? darkTextColor : lightTextColor,
isDark.value ? darkLineColor : lightLineColor);
2023-07-24 10:05:07 +08:00
});
2024-12-27 11:19:52 +08:00
2023-07-24 10:05:07 +08:00
return {
chartOption,
};
}