|
|
@@ -2,6 +2,7 @@
|
|
|
import * as echarts from 'echarts'
|
|
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
|
import type { Annotation, Cycle, MeasurementType, TimePoint, WaveWindowResponse } from '../types'
|
|
|
+import { fixedAxisRange } from '../utils/axis'
|
|
|
|
|
|
const props = defineProps<{
|
|
|
data: WaveWindowResponse | null
|
|
|
@@ -55,6 +56,13 @@ function niceAxisExtent(values: number[]): [number, number] {
|
|
|
return [Math.floor(min / interval) * interval, Math.ceil(max / interval) * interval]
|
|
|
}
|
|
|
|
|
|
+function fixedYAxis(type: string) {
|
|
|
+ if (props.mode === 'merge') return null
|
|
|
+ if (type !== '压力' && type !== '位移' && type !== '加速度') return null
|
|
|
+ const series = props.data?.series.find((item) => item.measurementType === type)
|
|
|
+ return fixedAxisRange(type, series?.min, series?.max)
|
|
|
+}
|
|
|
+
|
|
|
const plottedPointCount = computed(() => (
|
|
|
(props.data?.series.reduce((total, series) => total + series.data.length, 0) ?? 0)
|
|
|
+ (props.data?.secondSeries.data.length ?? 0)
|
|
|
@@ -257,20 +265,24 @@ function buildOption(zoomMode: 'initial' | 'keep' = 'initial') {
|
|
|
boundaryGap: false,
|
|
|
splitLine: { show: false },
|
|
|
}))
|
|
|
- const yAxes = types.map((type, index) => ({
|
|
|
- type: 'value' as const,
|
|
|
- gridIndex: index,
|
|
|
- name: type === 'second_value' ? '周期数据' : type,
|
|
|
- nameLocation: 'middle' as const,
|
|
|
- nameGap: 48,
|
|
|
- nameTextStyle: { color: colors[type as MeasurementType | '角度' | '合并信号' | 'second_value' | '体积'], fontWeight: 600 },
|
|
|
- axisLine: { show: true, lineStyle: { color: colors[type as MeasurementType | '角度' | '合并信号' | 'second_value' | '体积'] } },
|
|
|
- axisLabel: { color: '#71808a', fontSize: 11 },
|
|
|
- splitLine: { show: true, lineStyle: { color: '#e7edf0', width: 1 } },
|
|
|
- scale: type === '位移',
|
|
|
- min: type === '角度' ? 0 : undefined,
|
|
|
- max: type === '角度' ? 180 : undefined,
|
|
|
- }))
|
|
|
+ const yAxes = types.map((type, index) => {
|
|
|
+ const fixed = fixedYAxis(type)
|
|
|
+ return {
|
|
|
+ type: 'value' as const,
|
|
|
+ gridIndex: index,
|
|
|
+ name: type === 'second_value' ? '周期数据' : type,
|
|
|
+ nameLocation: 'middle' as const,
|
|
|
+ nameGap: 48,
|
|
|
+ nameTextStyle: { color: colors[type as MeasurementType | '角度' | '合并信号' | 'second_value' | '体积'], fontWeight: 600 },
|
|
|
+ axisLine: { show: true, lineStyle: { color: colors[type as MeasurementType | '角度' | '合并信号' | 'second_value' | '体积'] } },
|
|
|
+ axisLabel: { color: '#71808a', fontSize: 11 },
|
|
|
+ splitLine: { show: true, lineStyle: { color: '#e7edf0', width: 1 } },
|
|
|
+ scale: type === '位移',
|
|
|
+ min: type === '角度' ? 0 : fixed?.min,
|
|
|
+ max: type === '角度' ? 180 : fixed?.max,
|
|
|
+ interval: type === '角度' ? undefined : fixed?.interval,
|
|
|
+ }
|
|
|
+ })
|
|
|
const series: echarts.SeriesOption[] = []
|
|
|
if (props.mode === 'merge') {
|
|
|
const normalised = measurementTypes.map((type) => {
|
|
|
@@ -479,7 +491,8 @@ function drawPvPreviews() {
|
|
|
const data = props.data
|
|
|
if (!canvas || !shell || !data || !chart) return
|
|
|
const height = 132
|
|
|
- const pressure = data.series.find((series) => series.measurementType === '压力')?.data ?? []
|
|
|
+ const pressureSeries = data.series.find((series) => series.measurementType === '压力')
|
|
|
+ const pressure = pressureSeries?.data ?? []
|
|
|
const xPixel = (value: number) => Number(chart?.convertToPixel({ xAxisIndex: 0 }, value))
|
|
|
const zoom = readCurrentZoom(data)
|
|
|
const visibleMin = data.xMin + (data.xMax - data.xMin) * zoom.start / 100
|
|
|
@@ -547,7 +560,8 @@ function drawPvPreviews() {
|
|
|
const volumes = points.map((point) => point.volume as number)
|
|
|
const pressures = points.map((point) => point.rawValue)
|
|
|
const [minVolume, maxVolume] = niceAxisExtent(volumes)
|
|
|
- const [minPressure, maxPressure] = niceAxisExtent(pressures)
|
|
|
+ const fixedPressure = fixedAxisRange('压力', pressureSeries?.min, pressureSeries?.max)
|
|
|
+ const [minPressure, maxPressure] = fixedPressure ? [fixedPressure.min, fixedPressure.max] : niceAxisExtent(pressures)
|
|
|
const volumeSpan = maxVolume - minVolume || 1
|
|
|
const pressureSpan = maxPressure - minPressure || 1
|
|
|
const frameWidth = Math.min(cycleWidth, height * modalChartWidth / modalChartHeight)
|