yeg
2026-09-08 67a1dd5da47aea8c5e67272ea7711204e5e4d401
集成 Ticket04 对比图表交互
1个文件已修改
6 ■■■■■ 已修改文件
src/utils/reportMeasurementChart.ts 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/reportMeasurementChart.ts
@@ -17,6 +17,7 @@
  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 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,
@@ -28,8 +29,9 @@
  })
  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, name: '相对时间 / s', nameLocation: 'middle', nameGap: 28,
    // 使用 ECharts 原生图例承载曲线显隐;外部图例仍用于来源说明和改色。
    tooltip: { trigger: 'axis' }, legend: { show: true, type: 'scroll', top: 0, left: 32, right: 32, itemWidth: 12, itemHeight: 8, textStyle: { color: '#52606d', fontSize: 10 } },
    xAxis: { type: 'value', min: 0, max: timeMax > 0 ? timeMax : undefined, name: '相对时间 / s', nameLocation: 'middle', nameGap: 28,
      axisLine: { lineStyle: { color: '#cbd8e4' } }, axisLabel: { color: '#8795a3', fontSize: 10 },
      nameTextStyle: { color: '#26333f', fontSize: 11, fontWeight: 600 } },
    yAxis: [yAxis('left'), yAxis('right')],