From f102e9c661d31faca33f91f3ba3f98569c69a684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=90=AF=E6=BA=90?= Date: Thu, 23 Jul 2026 11:59:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(tooltip):=20=E4=BF=9D=E6=8C=81=E6=95=B0?= =?UTF-8?q?=E5=80=BC=E4=B8=8E=E5=8D=95=E4=BD=8D=E5=8D=95=E8=A1=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- .../interaction/WaveformTooltip.test.ts | 25 +++++++++++++++++++ .../interaction/WaveformTooltip.vue | 8 ++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 318e868..07fe3ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "waveform-analysis", - "version": "0.1.18", + "version": "0.1.19", "main": "./dist/index.cjs", "module": "./dist/index.js", "types": "./dist/types/index.d.ts", diff --git a/src/components/interaction/WaveformTooltip.test.ts b/src/components/interaction/WaveformTooltip.test.ts index 4ff12f5..07e81d5 100644 --- a/src/components/interaction/WaveformTooltip.test.ts +++ b/src/components/interaction/WaveformTooltip.test.ts @@ -66,6 +66,31 @@ describe('WaveformTooltip', () => { expect(wrapper.get('.waveform-tooltip__series small').text()).toBe('(+2 / -1)') }) + it('keeps a formatted value and its unit in one value container', () => { + const hoveredPoint = { x: 1, y: -1405.4932 } + const wrapper = mount(WaveformTooltip, { + props: { + visible: true, + position: { x: 10, y: 10 }, + timeUnit: 'ms', + hoveredPoint, + seriesPoints: [ + { + trackIndex: 0, + name: 'ENG8KJXAc(10001)', + color: '#ffb43b', + unit: 'A', + point: hoveredPoint, + }, + ], + containerWidth: 400, + containerHeight: 300, + }, + }) + + expect(wrapper.get('.waveform-tooltip__value').text()).toBe('-1,405.4932 A') + }) + it('omits the error label when both resolved errors are zero', () => { const point = { x: 1, y: 12 } const wrapper = mount(WaveformTooltip, { diff --git a/src/components/interaction/WaveformTooltip.vue b/src/components/interaction/WaveformTooltip.vue index 50062f0..79fc3d9 100644 --- a/src/components/interaction/WaveformTooltip.vue +++ b/src/components/interaction/WaveformTooltip.vue @@ -77,7 +77,7 @@ function formatError(point: WaveformPoint): string | null { > {{ seriesPoint.name }}: - + {{ formatTooltipNumber(seriesPoint.point.y) }}{{ seriesPoint.unit ? ` ${seriesPoint.unit}` : '' }} {{ formatError(seriesPoint.point) }} @@ -116,7 +116,7 @@ function formatError(point: WaveformPoint): string | null { .waveform-tooltip__series { display: grid; - grid-template-columns: 8px auto minmax(0, 1fr); + grid-template-columns: 8px minmax(0, 1fr) auto; gap: 6px; align-items: center; } @@ -134,6 +134,10 @@ function formatError(point: WaveformPoint): string | null { white-space: nowrap; } +.waveform-tooltip__value { + white-space: nowrap; +} + .waveform-tooltip__series small { color: #667085; white-space: nowrap;