From 61ee760f5203cf4a8540cc971c297495999ceee2 Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Wed, 10 Dec 2025 11:17:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=8B=E5=8A=BF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/echartMethod.ts | 72 +++++ .../home/components/compareDataCheckChart.vue | 265 ++++++++++++++++++ ...eDataCheckSingleChannelSingleTestPopup.vue | 7 + 3 files changed, 344 insertions(+) create mode 100644 frontend/src/utils/echartMethod.ts create mode 100644 frontend/src/views/home/components/compareDataCheckChart.vue diff --git a/frontend/src/utils/echartMethod.ts b/frontend/src/utils/echartMethod.ts new file mode 100644 index 0000000..1896fa0 --- /dev/null +++ b/frontend/src/utils/echartMethod.ts @@ -0,0 +1,72 @@ +const dataProcessing = (arr: any[]) => { + return arr + .filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item)))) + .map(item => (typeof item === 'number' ? item : parseFloat(item))) +} + +const calculateValue = (o: number, value: number, num: number, isMin: boolean) => { + if (value === 0) { + return 0 + } else if (value > 0 && Math.abs(value) < 1 && isMin == true) { + return 0 + } else if (value > -1 && value < 0 && isMin == false) { + return 0 + } + + let base + if (Math.abs(o) >= 100) { + base = 100 + } else if (Math.abs(o) >= 10) { + base = 10 + } else if (Math.abs(o) >= 1) { + base = 1 + } else { + const multiple = 1 / 0.1 + + base = Math.ceil(Math.abs(o) * multiple) / multiple + } + + let calculatedValue + if (isMin) { + if (value < 0) { + calculatedValue = value + num * value + } else { + calculatedValue = value - num * value + } + } else { + if (value < 0) { + calculatedValue = value - num * value + } else { + calculatedValue = value + num * value + } + } + + if (base === 0.1) { + return parseFloat(calculatedValue.toFixed(1)) + } else if (isMin) { + return Math.floor(calculatedValue / base) * base + } else { + return Math.ceil(calculatedValue / base) * base + } +} + +// 处理y轴最大最小值 +export const yMethod = (arr: any) => { + const num = 0.2 + const numList = dataProcessing(arr) + let maxValue = 0 + let minValue = 0 + let max = 0 + let min = 0 + maxValue = Math.max(...numList) + minValue = Math.min(...numList) + const o = maxValue - minValue == 0 ? maxValue : maxValue - minValue + min = calculateValue(o, minValue, num, true) + + max = calculateValue(o, maxValue, num, false) + + return [min, max] +} + + + diff --git a/frontend/src/views/home/components/compareDataCheckChart.vue b/frontend/src/views/home/components/compareDataCheckChart.vue new file mode 100644 index 0000000..794e8c5 --- /dev/null +++ b/frontend/src/views/home/components/compareDataCheckChart.vue @@ -0,0 +1,265 @@ + + + + diff --git a/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue b/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue index 387a7bf..f991e89 100644 --- a/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue +++ b/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue @@ -160,6 +160,12 @@ :currentScriptTypeName="currentScriptTypeName" /> + + + @@ -172,6 +178,7 @@ import { dialogBig } from '@/utils/elementBind' import { computed, reactive, ref } from 'vue' import CompareDataCheckResultTable from './compareDataCheckResultTable.vue' import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue' +import CompareDataCheckChart from './compareDataCheckChart.vue' import { CheckData } from '@/api/check/interface' import { useCheckStore } from '@/stores/modules/check' import { Histogram, Postcard } from '@element-plus/icons-vue'