fix(tooltip): 保持数值与单位单行显示
All checks were successful
Package component / package (push) Successful in 2m52s
All checks were successful
Package component / package (push) Successful in 2m52s
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "waveform-analysis",
|
"name": "waveform-analysis",
|
||||||
"version": "0.1.18",
|
"version": "0.1.19",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
"module": "./dist/index.js",
|
"module": "./dist/index.js",
|
||||||
"types": "./dist/types/index.d.ts",
|
"types": "./dist/types/index.d.ts",
|
||||||
|
|||||||
@@ -66,6 +66,31 @@ describe('WaveformTooltip', () => {
|
|||||||
expect(wrapper.get('.waveform-tooltip__series small').text()).toBe('(+2 / -1)')
|
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', () => {
|
it('omits the error label when both resolved errors are zero', () => {
|
||||||
const point = { x: 1, y: 12 }
|
const point = { x: 1, y: 12 }
|
||||||
const wrapper = mount(WaveformTooltip, {
|
const wrapper = mount(WaveformTooltip, {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ function formatError(point: WaveformPoint): string | null {
|
|||||||
>
|
>
|
||||||
<i :style="{ backgroundColor: seriesPoint.color }" />
|
<i :style="{ backgroundColor: seriesPoint.color }" />
|
||||||
<strong v-if="seriesPoint.name">{{ seriesPoint.name }}:</strong>
|
<strong v-if="seriesPoint.name">{{ seriesPoint.name }}:</strong>
|
||||||
<span>
|
<span class="waveform-tooltip__value">
|
||||||
{{ formatTooltipNumber(seriesPoint.point.y)
|
{{ formatTooltipNumber(seriesPoint.point.y)
|
||||||
}}{{ seriesPoint.unit ? ` ${seriesPoint.unit}` : '' }}
|
}}{{ seriesPoint.unit ? ` ${seriesPoint.unit}` : '' }}
|
||||||
<small v-if="formatError(seriesPoint.point)">{{ formatError(seriesPoint.point) }}</small>
|
<small v-if="formatError(seriesPoint.point)">{{ formatError(seriesPoint.point) }}</small>
|
||||||
@@ -116,7 +116,7 @@ function formatError(point: WaveformPoint): string | null {
|
|||||||
|
|
||||||
.waveform-tooltip__series {
|
.waveform-tooltip__series {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 8px auto minmax(0, 1fr);
|
grid-template-columns: 8px minmax(0, 1fr) auto;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@@ -134,6 +134,10 @@ function formatError(point: WaveformPoint): string | null {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.waveform-tooltip__value {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.waveform-tooltip__series small {
|
.waveform-tooltip__series small {
|
||||||
color: #667085;
|
color: #667085;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
Reference in New Issue
Block a user