vehicle-monitor/src/views/data-analyse/components/data-analyse-right.vue

100 lines
2.2 KiB
Vue
Raw Normal View History

<script lang="ts" setup>
2025-05-24 19:31:33 +08:00
import { useIntervalFn } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { onMounted, ref } from 'vue';
2025-05-24 19:31:33 +08:00
import { useDataAnalyseHook } from '@/store/modules/dataAnalyse';
2025-05-11 22:17:16 +08:00
import { renderBodyChart } from '@/views/data-analyse/charts/right-body';
import { renderFooterChart } from '@/views/data-analyse/charts/right-footer';
2025-05-24 19:31:33 +08:00
import { renderTopChart, updateTopChart } from '@/views/data-analyse/charts/right-top';
2025-05-12 17:12:01 +08:00
import PanelTitle from '@/views/data-analyse/components/PanelTitle.vue';
2025-05-24 19:31:33 +08:00
const topChartRef = ref();
const bodyChartRef = ref();
const footerChartRef = ref();
2025-05-24 19:31:33 +08:00
const dataAnalyseHook = useDataAnalyseHook();
const { dataRatio } = storeToRefs(dataAnalyseHook);
/* 渲染图表 */
const renderChart = () => {
renderTopChart(topChartRef);
renderBodyChart(bodyChartRef);
2025-05-11 22:17:16 +08:00
renderFooterChart(footerChartRef);
};
2025-05-24 19:31:33 +08:00
const initAppData = async () => {
await dataAnalyseHook.fetchDataRatio();
updateTopChart(dataRatio.value);
};
onMounted(() => {
2025-05-24 19:31:33 +08:00
renderChart();
initAppData();
useIntervalFn(() => {
initAppData();
}, 10000);
});
</script>
2025-04-16 23:11:49 +08:00
<template>
<div class="data-analyse-right">
<header class="data-analyse-right__header">
2025-05-12 17:12:01 +08:00
<PanelTitle title="数据占有率" />
2025-05-24 19:31:33 +08:00
<div ref="topChartRef" class="data-analyse-right__header-chart" />
</header>
<main class="data-analyse-right__body">
2025-05-12 17:12:01 +08:00
<PanelTitle title="数据分析展示" />
2025-05-11 22:17:16 +08:00
<div ref="bodyChartRef" class="data-analyse-right__body-chart" />
</main>
<footer class="data-analyse-right__footer">
2025-05-12 17:12:01 +08:00
<PanelTitle title="数据展示统计" />
<div ref="footerChartRef" class="data-analyse-right__footer-chart" />
</footer>
</div>
2025-04-16 23:11:49 +08:00
</template>
<style lang="scss" scoped>
.data-analyse-right {
width: 496px;
height: 970px;
&__header {
margin: 10px 0 0 0;
width: 100%;
height: 305px;
2025-05-24 19:31:33 +08:00
&-chart {
width: 100%;
height: 100%;
}
}
&__body {
2025-05-11 22:17:16 +08:00
margin: 10px;
width: 100%;
height: 350px;
2025-05-11 22:17:16 +08:00
&-chart {
width: 100%;
height: 320px;
}
}
&__footer {
margin: 10px 0 0 0;
width: 100%;
height: 257px;
&-chart {
width: 100%;
height: 100%;
}
}
2025-04-16 23:11:49 +08:00
}
</style>