From 528d52f2c7c6f911c54cae6e3f25500eab4384fe Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期三, 09 九月 2026 02:32:43 +0800
Subject: [PATCH] 统一报表图表并接通首页与负责人待办
---
src/utils/reportMeasurementChart.ts | 30 ++----------------------------
1 files changed, 2 insertions(+), 28 deletions(-)
diff --git a/src/utils/reportMeasurementChart.ts b/src/utils/reportMeasurementChart.ts
index 54b1f08..9a0e21a 100644
--- a/src/utils/reportMeasurementChart.ts
+++ b/src/utils/reportMeasurementChart.ts
@@ -1,3 +1,4 @@
+import { stepCurveChartOption } from './stepCurveChart'
import type { PersistedTestRecord } from '@/api/tests'
import { toTestDisplayValue } from './testDataUnits'
@@ -14,32 +15,5 @@
const value = row[field[metric.key]]
return [[(Number(time) - item.zeroTime) / 1000, value == null ? null : toTestDisplayValue(metric.key, Number(value))] as [number, number | null]]
}).sort((left, right) => left[0] - right[0]))
- const [dataMin, dataMax] = series.reduce<[number, number]>(([min, max], points) => points.reduce<[number, number]>(([low, high], [, value]) =>
- value === null ? [low, high] : [Math.min(low, value), Math.max(high, value)], [min, max]), [0, 0])
- const range = Math.max(dataMax - dataMin, 1)
- const timeMax = series.reduce((max, points) => points.reduce((value, [time]) => Math.max(value, time), max), 0)
- const timeUnit = timeMax >= 3600 ? 3600 : timeMax >= 180 ? 60 : 1
- const timeLabel = timeUnit === 3600 ? 'h' : timeUnit === 60 ? 'min' : 's'
- const axisMax = Math.max(metric.unit === '℃' ? Math.ceil(dataMax / 10) * 10 : Math.ceil(dataMax * 10) / 10, 1)
- const yAxis = (position: 'left' | 'right') => ({
- type: 'value', name: metric.unit, position, min: dataMin - range * 0.05, max: axisMax,
- nameTextStyle: { color: '#8795a3', fontSize: 10 },
- axisLine: { show: true, lineStyle: { color: '#cbd8e4' } },
- axisTick: { show: true, lineStyle: { color: '#cbd8e4' } },
- splitLine: { show: position === 'left', lineStyle: { color: '#e8eef4' } },
- axisLabel: { color: '#8795a3', fontSize: 10, formatter: (value: number) => Number(value.toPrecision(6)).toString() },
- })
- return {
- animation: false, color: colors, grid: { top: 40, right: 32, bottom: 42, left: 32, containLabel: true },
- tooltip: { trigger: 'axis' }, legend: { show: false },
- xAxis: { type: 'value', min: 0, max: timeMax > 0 ? timeMax : undefined, splitNumber: 4, name: `相对时间 / ${timeLabel}`, nameLocation: 'middle', nameGap: 28,
- axisLine: { lineStyle: { color: '#cbd8e4' } }, axisLabel: { color: '#8795a3', fontSize: 10, hideOverlap: true,
- formatter: (value: number) => Number((value / timeUnit).toFixed(3)).toString() },
- nameTextStyle: { color: '#26333f', fontSize: 11, fontWeight: 600 } },
- yAxis: [yAxis('left'), yAxis('right')],
- // 全部冻结点先参与坐标计算;隐藏仅控制渲染,不重算零点、不缩短范围、不移动其他来源颜色。
- series: items.flatMap((item, index) => item.hidden ? [] : [{ name: item.name, type: 'line', smooth: false,
- connectNulls: false, showSymbol: true, symbolSize: 5, itemStyle: { color: colors[index % colors.length] },
- lineStyle: { width: 2, color: colors[index % colors.length] }, data: series[index] || [] }]),
- }
+ return stepCurveChartOption(metric, items.map((item, index) => ({ name: item.name, hidden: item.hidden, points: series[index] || [] })), colors)
}
--
Gitblit v1.7.1