Browse Source

fix: 图表显示

master
guoapeng 1 week ago
parent
commit
c5c6a0e0c1
  1. 4
      src/components/home/HomeFormula.vue
  2. 3
      src/components/home/LineChart.vue
  3. 28
      src/views/home/chart.vue

4
src/components/home/HomeFormula.vue

@ -54,7 +54,9 @@ watchEffect(async () => {
<el-descriptions-item label="实时消毒等级"> <el-descriptions-item label="实时消毒等级">
<el-tag> <el-tag>
<span style="color: #31cb7a; font-size: 18px; margin: 0 5px">{{ homeStore.disinfectionState.nlog }}</span>Log
<span style="color: #31cb7a; font-size: 18px; margin: 0 5px">{{
homeStore.disinfectionState.nlog?.toFixed(2)
}}</span>Log
</el-tag> </el-tag>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>

3
src/components/home/LineChart.vue

@ -128,6 +128,7 @@ watch(
], ],
} }
myChart.setOption(option) myChart.setOption(option)
myChart.resize()
}, },
{ {
deep: true, deep: true,
@ -142,7 +143,7 @@ onMounted(() => {
</script> </script>
<template> <template>
<div ref="chartRef" style="height: 100%" />
<div ref="chartRef" style="height: 100%; width: 50%" />
</template> </template>
<style scoped></style> <style scoped></style>

28
src/views/home/chart.vue

@ -118,6 +118,8 @@ const operationState = computed(() => {
let poll: any = null let poll: any = null
const chartRefs = ref([])
const getData = async (type?: string) => { const getData = async (type?: string) => {
const data = await syncSendCmd({ const data = await syncSendCmd({
className: 'H2O2SensorMgr', className: 'H2O2SensorMgr',
@ -199,7 +201,9 @@ const formatSeconds = (seconds: number) => {
<el-descriptions-item label="实时消毒等级"> <el-descriptions-item label="实时消毒等级">
<el-tag> <el-tag>
<span style="color: #31cb7a; font-size: 18px; margin: 0 5px">{{ homeStore.disinfectionState.nlog }}</span>Log
<span style="color: #31cb7a; font-size: 18px; margin: 0 5px">{{
homeStore.disinfectionState.nlog?.toFixed(2)
}}</span>Log
</el-tag> </el-tag>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
@ -208,7 +212,14 @@ const formatSeconds = (seconds: number) => {
class="line-chart-content" class="line-chart-content"
:style="{ 'grid-template-columns': `repeat(${chartList.length},1fr)` }" :style="{ 'grid-template-columns': `repeat(${chartList.length},1fr)` }"
> >
<LineChart v-for="(item, index) in chartList" :key="index" :env-data="item" />
<LineChart
v-for="(item, index) in chartList"
ref="chartRefs"
:key="index"
class="chart-box"
:style="{ width: `calc(100% / ${chartList.length} - 10px)` }"
:env-data="item"
/>
</div> </div>
<div class="line-chart-bottom"> <div class="line-chart-bottom">
<div class="home-chart-time"> <div class="home-chart-time">
@ -296,8 +307,19 @@ const formatSeconds = (seconds: number) => {
align-items: center; align-items: center;
} }
.line-chart-content { .line-chart-content {
display: grid;
display: flex;
flex-direction: row; //
align-items: flex-start; //
overflow-x: auto; //
width: 100%;
height: calc(100% - 80px); height: calc(100% - 80px);
gap: 10px;
.chart-box {
flex: 0 0 auto;
width: 100%;
height: 100%;
min-width: 200px;
}
} }
.line-chart-bottom { .line-chart-bottom {
height: 40px; height: 40px;

Loading…
Cancel
Save