Files
orion-visor/orion-ops-ui/src/components/view/chart/index.vue

46 lines
925 B
Vue
Raw Normal View History

2023-07-24 10:05:07 +08:00
<template>
2024-04-06 23:11:30 +08:00
<v-charts v-if="renderChart"
:option="options"
:autoresize="autoResize"
:style="{ width, height }" />
2023-07-24 10:05:07 +08:00
</template>
<script lang="ts" setup>
2024-04-15 14:08:00 +08:00
import type { EChartsOption } from 'echarts';
2024-04-06 23:11:30 +08:00
import { computed, nextTick, ref } from 'vue';
import { useAppStore } from '@/store';
2023-07-24 10:05:07 +08:00
import VCharts from 'vue-echarts';
2024-04-06 23:11:30 +08:00
const props = withDefaults(defineProps<{
2024-04-15 14:08:00 +08:00
options: EChartsOption,
2024-04-06 23:11:30 +08:00
autoResize: boolean,
width: string,
height: string,
}>(), {
options: () => {
return {};
2023-07-24 10:05:07 +08:00
},
2024-04-06 23:11:30 +08:00
autoResize: true,
width: '100%',
height: '100%',
});
const appStore = useAppStore();
// 监听暗色模式
const theme = computed(() => {
if (appStore.theme === 'dark') return 'dark';
return '';
2023-07-24 10:05:07 +08:00
});
2024-04-06 23:11:30 +08:00
2023-07-24 10:05:07 +08:00
const renderChart = ref(false);
2024-04-06 23:11:30 +08:00
2023-07-24 10:05:07 +08:00
nextTick(() => {
renderChart.value = true;
});
2024-04-06 23:11:30 +08:00
2023-07-24 10:05:07 +08:00
</script>
2023-10-25 10:26:14 +08:00
<style lang="less" scoped>
</style>