waveform-analysis 0.1.62 → 0.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +953 -946
- package/dist/style.css +1 -1
- package/dist/types/types/chart.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/WaveformChart.vue +1 -1
- package/src/components/core/xDomain.ts +26 -2
- package/src/components/rendering/WaveformLegend.vue +1 -1
- package/src/components/rendering/WaveformSeriesLayer.vue +1 -1
- package/src/demo/DemoChartHost.vue +1 -0
- package/src/types/chart.ts +2 -1
- package/src/App.test.ts +0 -400
- package/src/components/annotation/components.test.ts +0 -372
- package/src/components/annotation/markup.test.ts +0 -371
- package/src/components/annotation/serialization.test.ts +0 -114
- package/src/components/core/constants.test.ts +0 -29
- package/src/components/core/fixedYDomainLayout.test.ts +0 -204
- package/src/components/core/grid.test.ts +0 -197
- package/src/components/core/latestTaskScheduler.test.ts +0 -51
- package/src/components/core/layout.test.ts +0 -373
- package/src/components/core/title.test.ts +0 -76
- package/src/components/core/useWaveformData.test.ts +0 -95
- package/src/components/core/useWaveformRenderSampling.test.ts +0 -17
- package/src/components/core/xDomain.test.ts +0 -28
- package/src/components/core/yAxisNice.test.ts +0 -174
- package/src/components/core/yAxisSlotLayout.test.ts +0 -165
- package/src/components/core/yDomain.test.ts +0 -56
- package/src/components/interaction/WaveformTooltip.test.ts +0 -276
- package/src/components/interaction/viewportInteractionState.test.ts +0 -101
- package/src/components/utils/useAnimationFrameThrottle.test.ts +0 -53
- package/src/components/waveformChartCases/annotationEditingAndReprojection.test.ts +0 -257
- package/src/components/waveformChartCases/compactAndSharedHover.test.ts +0 -358
- package/src/components/waveformChartCases/dataAndHoverPerformance.test.ts +0 -358
- package/src/components/waveformChartCases/dataLifecycle.test.ts +0 -310
- package/src/components/waveformChartCases/frameGridAndFormatting.test.ts +0 -389
- package/src/components/waveformChartCases/gridFill.test.ts +0 -95
- package/src/components/waveformChartCases/incompleteDataHover.test.ts +0 -155
- package/src/components/waveformChartCases/interactionAndAnnotationCreation.test.ts +0 -328
- package/src/components/waveformChartCases/layoutAndDomains.test.ts +0 -371
- package/src/components/waveformChartCases/legendVisibility.test.ts +0 -350
- package/src/components/waveformChartCases/multiAxisAndPagination.test.ts +0 -400
- package/src/components/waveformChartCases/multiAxisLabelAlignment.test.ts +0 -61
- package/src/components/waveformChartCases/presentationAndAxes.test.ts +0 -345
- package/src/components/waveformChartCases/presentationMode.test.ts +0 -327
- package/src/components/waveformChartCases/renderingStyles.test.ts +0 -283
- package/src/components/waveformChartCases/sizingAndTitles.test.ts +0 -370
- package/src/components/waveformChartCases/trackOrder.test.ts +0 -323
- package/src/components/waveformChartCases/viewportBoxAndPan.test.ts +0 -365
- package/src/components/waveformChartCases/viewportConstraintsAndReset.test.ts +0 -311
- package/src/components/waveformChartCases/viewportLifecycle.test.ts +0 -132
- package/src/components/waveformChartCases/viewportReset.test.ts +0 -251
- package/src/components/waveformChartCases/wheelZoomOut.test.ts +0 -114
- package/src/components/waveformChartCases/workerSamplingIntegration.test.ts +0 -117
- package/src/components/waveformChartCases/xDomainStrategy.test.ts +0 -168
- package/src/components/waveformChartCases/yAxisLayout.test.ts +0 -103
- package/src/components/waveformChartCases/zoomIntentAndDataRebind.test.ts +0 -213
- package/src/components/waveformChartCases/zoomPointConstraints.test.ts +0 -308
- package/src/components/waveformLegendGeometry.test.ts +0 -21
- package/src/components/waveformNormalization.test.ts +0 -170
- package/src/core/data.test.ts +0 -241
- package/src/core/rendering.test.ts +0 -267
- package/src/core/renderingStrategies.test.ts +0 -90
- package/src/core/samplingReference.test.ts +0 -124
- package/src/core/wasmSampling.test.ts +0 -205
- package/src/core/workerSampling/multiresolution.test.ts +0 -69
- package/src/core/workerSampling/protocol.test.ts +0 -34
- package/src/core/workerSampling/repository.test.ts +0 -400
- package/src/core/workerSampling/repositoryCache.test.ts +0 -163
- package/src/core/workerSampling/repositorySampling.test.ts +0 -106
- package/src/core/workerSampling/repositoryTypedDataset.test.ts +0 -89
- package/src/core/workerSampling/repositoryWasmDataset.test.ts +0 -70
- package/src/data/simulatedWaveforms.test.ts +0 -60
- package/src/demo/plotMarginControls.test.ts +0 -29
- package/src/demo/xAxisLabelControls.test.ts +0 -86
- package/src/test/setup.ts +0 -82
- package/src/test/waveformChart.ts +0 -75
- package/src/utils/domain.test.ts +0 -28
- package/src/utils/formatters.test.ts +0 -131
- package/src/utils/sampling.test.ts +0 -226
- package/src/views/FixedYDomainDemo.test.ts +0 -44
- package/src/views/WasmSamplingDemo.test.ts +0 -13
- package/src/views/wasmSamplingDemoSampling.test.ts +0 -27
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { flushPromises } from '@vue/test-utils'
|
|
2
|
-
import { describe, expect, it } from 'vitest'
|
|
3
|
-
|
|
4
|
-
import { flushAnimationFrames } from '../../test/setup'
|
|
5
|
-
import { type WaveformData } from '../waveform'
|
|
6
|
-
import WaveformChartView from '../WaveformChartView.vue'
|
|
7
|
-
|
|
8
|
-
import { gridSeries, mountSizedChart, visibilitySeries } from '../../test/waveformChart'
|
|
9
|
-
|
|
10
|
-
function annotationEditorExists() {
|
|
11
|
-
return Boolean(
|
|
12
|
-
Array.from(document.body.querySelectorAll<HTMLElement>('[role="dialog"]'))
|
|
13
|
-
.filter((element) => element.closest('.waveform-annotation-editor'))
|
|
14
|
-
.at(-1),
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe('WaveformChart', () => {
|
|
19
|
-
it('shows legends when a track contains at least two series', async () => {
|
|
20
|
-
const oneSeries = visibilitySeries()
|
|
21
|
-
if (oneSeries.kind === 'series') oneSeries.series = oneSeries.series.slice(0, 1)
|
|
22
|
-
const withoutLegend = await mountSizedChart(oneSeries, {
|
|
23
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
24
|
-
})
|
|
25
|
-
expect(withoutLegend.findAll('.waveform-chart__legend')).toHaveLength(0)
|
|
26
|
-
|
|
27
|
-
const twoSeries = visibilitySeries()
|
|
28
|
-
if (twoSeries.kind === 'series') twoSeries.series = twoSeries.series.slice(0, 2)
|
|
29
|
-
const withLegend = await mountSizedChart(twoSeries, {
|
|
30
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
31
|
-
})
|
|
32
|
-
expect(withLegend.findAll('.waveform-chart__legend')).toHaveLength(1)
|
|
33
|
-
expect(withLegend.find('.waveform-chart__legend').attributes('data-position')).toBe('top-right')
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('resolves legend positions by stable track id across pages', async () => {
|
|
37
|
-
const wrapper = await mountSizedChart(
|
|
38
|
-
{
|
|
39
|
-
kind: 'series',
|
|
40
|
-
series: Array.from({ length: 12 }, (_, index) => ({
|
|
41
|
-
id: `series-${index}`,
|
|
42
|
-
trackId: `frame-${Math.floor(index / 3)}`,
|
|
43
|
-
name: `series ${index}`,
|
|
44
|
-
data: {
|
|
45
|
-
kind: 'points' as const,
|
|
46
|
-
points: [
|
|
47
|
-
{ x: 0, y: index },
|
|
48
|
-
{ x: 1, y: index + 1 },
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
})),
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
grid: { rowCount: 2, columnCount: 1, showPagination: true },
|
|
55
|
-
legend: {
|
|
56
|
-
position: 'left',
|
|
57
|
-
orientation: 'auto',
|
|
58
|
-
trackPositions: {
|
|
59
|
-
'frame-0': 'top',
|
|
60
|
-
'frame-1': 'bottom-right',
|
|
61
|
-
'frame-2': 'bottom',
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
const legendForTrack = (trackId: string) =>
|
|
68
|
-
wrapper.get(`[data-legend-track-id="${trackId}"] .waveform-chart__legend`)
|
|
69
|
-
|
|
70
|
-
expect(legendForTrack('frame-0').attributes('data-position')).toBe('top')
|
|
71
|
-
expect(legendForTrack('frame-0').attributes('data-orientation')).toBe('horizontal')
|
|
72
|
-
expect(legendForTrack('frame-1').attributes('data-position')).toBe('bottom-right')
|
|
73
|
-
expect(legendForTrack('frame-1').attributes('data-orientation')).toBe('vertical')
|
|
74
|
-
|
|
75
|
-
await wrapper.setProps({
|
|
76
|
-
legend: {
|
|
77
|
-
position: 'left',
|
|
78
|
-
orientation: 'vertical',
|
|
79
|
-
trackPositions: { 'frame-0': 'top', 'frame-1': 'bottom-right', 'frame-2': 'bottom' },
|
|
80
|
-
},
|
|
81
|
-
})
|
|
82
|
-
expect(legendForTrack('frame-0').attributes('data-orientation')).toBe('vertical')
|
|
83
|
-
|
|
84
|
-
await wrapper.get('.ant-pagination-next button').trigger('click')
|
|
85
|
-
expect(legendForTrack('frame-2').attributes('data-position')).toBe('bottom')
|
|
86
|
-
expect(legendForTrack('frame-2').attributes('data-orientation')).toBe('vertical')
|
|
87
|
-
expect(legendForTrack('frame-3').attributes('data-position')).toBe('left')
|
|
88
|
-
expect(legendForTrack('frame-3').attributes('data-orientation')).toBe('vertical')
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('applies a configurable alpha background to every visible legend', async () => {
|
|
92
|
-
const wrapper = await mountSizedChart(
|
|
93
|
-
{
|
|
94
|
-
kind: 'series',
|
|
95
|
-
series: Array.from({ length: 6 }, (_, index) => ({
|
|
96
|
-
id: `series-${index}`,
|
|
97
|
-
trackId: `frame-${Math.floor(index / 3)}`,
|
|
98
|
-
name: `series ${index}`,
|
|
99
|
-
data: {
|
|
100
|
-
kind: 'points',
|
|
101
|
-
points: [
|
|
102
|
-
{ x: 0, y: index },
|
|
103
|
-
{ x: 1, y: index + 1 },
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
})),
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
grid: { rowCount: 2, columnCount: 1 },
|
|
110
|
-
legend: { backgroundColor: 'rgba(14, 165, 233, 0.25)' },
|
|
111
|
-
},
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
const legendPanels = wrapper.findAll('.waveform-legend__panel')
|
|
115
|
-
expect(legendPanels).toHaveLength(2)
|
|
116
|
-
legendPanels.forEach((panel) => {
|
|
117
|
-
expect(panel.attributes('style')).toContain('background-color: rgba(14, 165, 233, 0.25)')
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
await wrapper.setProps({ legend: { backgroundColor: '' } })
|
|
121
|
-
wrapper.findAll('.waveform-legend__panel').forEach((panel) => {
|
|
122
|
-
expect(panel.attributes('style')).toContain('background-color: rgba(255, 255, 255, 0.7)')
|
|
123
|
-
})
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('keeps legends display-only unless interaction is explicitly enabled', async () => {
|
|
127
|
-
const wrapper = await mountSizedChart(visibilitySeries(), {
|
|
128
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
const items = wrapper.findAll('.waveform-chart__legend-item')
|
|
132
|
-
expect(items).toHaveLength(3)
|
|
133
|
-
expect(items.every((item) => item.attributes('disabled') !== undefined)).toBe(true)
|
|
134
|
-
expect(wrapper.get('.waveform-legend__panel').classes()).not.toContain(
|
|
135
|
-
'waveform-legend__panel--interactive',
|
|
136
|
-
)
|
|
137
|
-
expect(wrapper.emitted('update:hidden-series-ids')).toBeUndefined()
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('toggles series, axes, tooltips, and annotations from an interactive legend', async () => {
|
|
141
|
-
const wrapper = await mountSizedChart(visibilitySeries(), {
|
|
142
|
-
annotations: [{ id: 'high-note', seriesId: 'high', x: 15, y: 1500, text: '高值' }],
|
|
143
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
144
|
-
legend: { interactive: true },
|
|
145
|
-
overlayMode: 'multi-axis',
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
expect(wrapper.findAll('.waveform-chart__axis--y')).toHaveLength(3)
|
|
149
|
-
expect(wrapper.find('[data-annotation-id="high-note"]').exists()).toBe(true)
|
|
150
|
-
const annotationLayer = wrapper.get('.waveform-annotation-layer').element
|
|
151
|
-
const legendLayer = wrapper.get('.waveform-chart__legend-layer').element
|
|
152
|
-
expect(
|
|
153
|
-
annotationLayer.compareDocumentPosition(legendLayer) & Node.DOCUMENT_POSITION_FOLLOWING,
|
|
154
|
-
).toBeTruthy()
|
|
155
|
-
const highLegendItem = wrapper.findAll('.waveform-chart__legend-item')[1]
|
|
156
|
-
expect(highLegendItem.attributes('aria-pressed')).toBe('true')
|
|
157
|
-
|
|
158
|
-
await highLegendItem.trigger('click')
|
|
159
|
-
await flushPromises()
|
|
160
|
-
|
|
161
|
-
expect(
|
|
162
|
-
wrapper.findAll('.waveform-chart__line').map((line) => line.attributes('data-series-id')),
|
|
163
|
-
).toEqual(['low', 'mid'])
|
|
164
|
-
expect(wrapper.findAll('.waveform-chart__axis--y')).toHaveLength(2)
|
|
165
|
-
expect(wrapper.find('[data-annotation-id="high-note"]').exists()).toBe(false)
|
|
166
|
-
expect(wrapper.findAll('.waveform-chart__legend-item')[1].classes()).toContain('is-hidden')
|
|
167
|
-
expect(wrapper.findAll('.waveform-chart__legend-item')[1].attributes('aria-pressed')).toBe(
|
|
168
|
-
'false',
|
|
169
|
-
)
|
|
170
|
-
expect(wrapper.emitted('update:hidden-series-ids')?.at(-1)).toEqual([['high']])
|
|
171
|
-
expect(wrapper.emitted('series-visibility-change')?.at(-1)).toEqual([
|
|
172
|
-
{ seriesId: 'high', visible: false, hiddenSeriesIds: ['high'] },
|
|
173
|
-
])
|
|
174
|
-
|
|
175
|
-
const overlay = wrapper.get('.waveform-chart__overlay--independent')
|
|
176
|
-
const overlayWidth = Number(overlay.attributes('width'))
|
|
177
|
-
const overlayHeight = Number(overlay.attributes('height'))
|
|
178
|
-
Object.defineProperty(overlay.element, 'getBoundingClientRect', {
|
|
179
|
-
value: () => ({ left: 0, top: 0, width: overlayWidth, height: overlayHeight }),
|
|
180
|
-
})
|
|
181
|
-
overlay.element.dispatchEvent(
|
|
182
|
-
new MouseEvent('pointermove', {
|
|
183
|
-
clientX: overlayWidth / 2,
|
|
184
|
-
clientY: overlayHeight / 2,
|
|
185
|
-
bubbles: true,
|
|
186
|
-
}),
|
|
187
|
-
)
|
|
188
|
-
flushAnimationFrames()
|
|
189
|
-
await flushPromises()
|
|
190
|
-
expect(wrapper.findAll('.waveform-chart__tooltip-series')).toHaveLength(2)
|
|
191
|
-
expect(wrapper.get('.waveform-chart__tooltip-series').text()).toContain('低量程')
|
|
192
|
-
|
|
193
|
-
await wrapper.findAll('.waveform-chart__legend-item')[1].trigger('click')
|
|
194
|
-
await flushPromises()
|
|
195
|
-
expect(wrapper.findAll('.waveform-chart__line')).toHaveLength(3)
|
|
196
|
-
expect(wrapper.find('[data-annotation-id="high-note"]').exists()).toBe(true)
|
|
197
|
-
expect(wrapper.emitted('series-visibility-change')?.at(-1)).toEqual([
|
|
198
|
-
{ seriesId: 'high', visible: true, hiddenSeriesIds: [] },
|
|
199
|
-
])
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
it('waits for controlled visibility updates and preserves unknown controlled IDs', async () => {
|
|
203
|
-
const wrapper = await mountSizedChart(visibilitySeries(), {
|
|
204
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
205
|
-
hiddenSeriesIds: ['high', 'temporarily-absent'],
|
|
206
|
-
legend: { interactive: true },
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
expect(
|
|
210
|
-
wrapper.findAll('.waveform-chart__line').map((line) => line.attributes('data-series-id')),
|
|
211
|
-
).toEqual(['low', 'mid'])
|
|
212
|
-
await wrapper.findAll('.waveform-chart__legend-item')[0].trigger('click')
|
|
213
|
-
expect(wrapper.emitted('update:hidden-series-ids')?.at(-1)).toEqual([
|
|
214
|
-
['high', 'temporarily-absent', 'low'],
|
|
215
|
-
])
|
|
216
|
-
expect(
|
|
217
|
-
wrapper.findAll('.waveform-chart__line').map((line) => line.attributes('data-series-id')),
|
|
218
|
-
).toEqual(['low', 'mid'])
|
|
219
|
-
|
|
220
|
-
await wrapper.setProps({ hiddenSeriesIds: ['low'] })
|
|
221
|
-
await flushPromises()
|
|
222
|
-
expect(
|
|
223
|
-
wrapper.findAll('.waveform-chart__line').map((line) => line.attributes('data-series-id')),
|
|
224
|
-
).toEqual(['high', 'mid'])
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
it('retains uncontrolled visibility by stable ID and clears removed IDs', async () => {
|
|
228
|
-
const original = visibilitySeries()
|
|
229
|
-
const wrapper = await mountSizedChart(original, {
|
|
230
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
231
|
-
legend: { interactive: true },
|
|
232
|
-
})
|
|
233
|
-
await wrapper.findAll('.waveform-chart__legend-item')[1].trigger('click')
|
|
234
|
-
|
|
235
|
-
const reversed: WaveformData = {
|
|
236
|
-
kind: 'series',
|
|
237
|
-
series: [...(original.kind === 'series' ? original.series : [])].reverse(),
|
|
238
|
-
}
|
|
239
|
-
await wrapper.setProps({ data: reversed })
|
|
240
|
-
await flushPromises()
|
|
241
|
-
expect(
|
|
242
|
-
wrapper.findAll('.waveform-chart__line').map((line) => line.attributes('data-series-id')),
|
|
243
|
-
).toEqual(['mid', 'low'])
|
|
244
|
-
|
|
245
|
-
await wrapper.setProps({
|
|
246
|
-
data: {
|
|
247
|
-
kind: 'series',
|
|
248
|
-
series: original.kind === 'series' ? [original.series[0]!] : [],
|
|
249
|
-
},
|
|
250
|
-
})
|
|
251
|
-
await flushPromises()
|
|
252
|
-
await wrapper.setProps({ data: original })
|
|
253
|
-
await flushPromises()
|
|
254
|
-
expect(wrapper.findAll('.waveform-chart__line')).toHaveLength(3)
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
it('keeps a recoverable legend and stops chart interaction when every series is hidden', async () => {
|
|
258
|
-
const wrapper = await mountSizedChart(visibilitySeries(), {
|
|
259
|
-
defaultHiddenSeriesIds: ['low', 'high', 'mid'],
|
|
260
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
261
|
-
legend: { interactive: true },
|
|
262
|
-
overlayMode: 'multi-axis',
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
expect(wrapper.findAll('.waveform-chart__line')).toHaveLength(0)
|
|
266
|
-
expect(wrapper.findAll('.waveform-chart__axis')).toHaveLength(0)
|
|
267
|
-
expect(wrapper.findAll('.waveform-chart__overlay')).toHaveLength(0)
|
|
268
|
-
expect(wrapper.findAll('.waveform-chart__legend-item')).toHaveLength(3)
|
|
269
|
-
expect(wrapper.get('.waveform-track__no-visible-series').text()).toBe('暂无可见曲线')
|
|
270
|
-
|
|
271
|
-
await wrapper.findAll('.waveform-chart__legend-item')[0].trigger('click')
|
|
272
|
-
await flushPromises()
|
|
273
|
-
expect(
|
|
274
|
-
wrapper.findAll('.waveform-chart__line').map((line) => line.attributes('data-series-id')),
|
|
275
|
-
).toEqual(['low'])
|
|
276
|
-
expect(wrapper.findAll('.waveform-chart__axis--x')).toHaveLength(1)
|
|
277
|
-
expect(wrapper.findAll('.waveform-chart__axis--y')).toHaveLength(1)
|
|
278
|
-
expect(wrapper.findAll('.waveform-chart__overlay--independent')).toHaveLength(1)
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
it('closes an annotation editor when its series is hidden from the legend', async () => {
|
|
282
|
-
const wrapper = await mountSizedChart(visibilitySeries(), {
|
|
283
|
-
grid: { rowCount: 1, columnCount: 1 },
|
|
284
|
-
legend: { interactive: true },
|
|
285
|
-
})
|
|
286
|
-
const overlay = wrapper.get('.waveform-chart__overlay--independent')
|
|
287
|
-
const overlayWidth = Number(overlay.attributes('width'))
|
|
288
|
-
const overlayHeight = Number(overlay.attributes('height'))
|
|
289
|
-
Object.defineProperty(overlay.element, 'getBoundingClientRect', {
|
|
290
|
-
value: () => ({ left: 0, top: 0, width: overlayWidth, height: overlayHeight }),
|
|
291
|
-
})
|
|
292
|
-
overlay.element.dispatchEvent(
|
|
293
|
-
new MouseEvent('contextmenu', {
|
|
294
|
-
clientX: overlayWidth * 0.75,
|
|
295
|
-
clientY: overlayHeight / 2,
|
|
296
|
-
bubbles: true,
|
|
297
|
-
}),
|
|
298
|
-
)
|
|
299
|
-
flushAnimationFrames()
|
|
300
|
-
await flushPromises()
|
|
301
|
-
expect(annotationEditorExists()).toBe(true)
|
|
302
|
-
|
|
303
|
-
const controller = wrapper.getComponent(WaveformChartView).props('controller') as unknown as {
|
|
304
|
-
annotationInteraction: { editorDraft: { value: { annotation: { seriesId: string } } | null } }
|
|
305
|
-
}
|
|
306
|
-
const draftSeriesId = controller.annotationInteraction.editorDraft.value?.annotation.seriesId
|
|
307
|
-
const item = wrapper
|
|
308
|
-
.findAll('.waveform-chart__legend-item')
|
|
309
|
-
.find((legendItem) =>
|
|
310
|
-
legendItem.text().includes(draftSeriesId === 'high' ? '高量程' : '低量程'),
|
|
311
|
-
)
|
|
312
|
-
expect(item).toBeDefined()
|
|
313
|
-
await item!.trigger('click')
|
|
314
|
-
await flushPromises()
|
|
315
|
-
expect(annotationEditorExists()).toBe(false)
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
it('renders independent cells with separate x axes and overlays', async () => {
|
|
319
|
-
const wrapper = await mountSizedChart(gridSeries(4), {
|
|
320
|
-
displayMode: 'independent',
|
|
321
|
-
grid: { rowCount: 2, columnCount: 2 },
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
expect(wrapper.findAll('.waveform-chart__track')).toHaveLength(4)
|
|
325
|
-
expect(wrapper.findAll('.waveform-chart__axis--x')).toHaveLength(4)
|
|
326
|
-
expect(wrapper.findAll('.waveform-chart__overlay--independent')).toHaveLength(4)
|
|
327
|
-
const tracks = wrapper.findAll('.waveform-chart__track')
|
|
328
|
-
const firstTop = Number(tracks[0].attributes('data-track-top'))
|
|
329
|
-
const secondRowTop = Number(tracks[2].attributes('data-track-top'))
|
|
330
|
-
const firstHeight = Number(tracks[0].attributes('data-track-height'))
|
|
331
|
-
expect(secondRowTop).toBeGreaterThan(firstTop + firstHeight + 20)
|
|
332
|
-
})
|
|
333
|
-
|
|
334
|
-
it('reserves horizontal clearance for Y-axis labels in multi-column grids', async () => {
|
|
335
|
-
for (const displayMode of ['independent', 'separated', 'compact'] as const) {
|
|
336
|
-
const wrapper = await mountSizedChart(gridSeries(4), {
|
|
337
|
-
displayMode,
|
|
338
|
-
grid: { rowCount: 2, columnCount: 2 },
|
|
339
|
-
})
|
|
340
|
-
const tracks = wrapper.findAll('.waveform-chart__track')
|
|
341
|
-
const firstLeft = Number(tracks[0].attributes('data-track-left') ?? 0)
|
|
342
|
-
const firstWidth = Number(tracks[0].attributes('data-track-width'))
|
|
343
|
-
const secondLeft = Number(tracks[1].attributes('data-track-left'))
|
|
344
|
-
const labelX = Number(tracks[1].attributes('data-y-axis-label-x'))
|
|
345
|
-
|
|
346
|
-
expect(secondLeft - (firstLeft + firstWidth)).toBeGreaterThanOrEqual(Math.abs(labelX) + 6)
|
|
347
|
-
expect(tracks[1].find('.waveform-chart__y-axis-label-bg').exists()).toBe(true)
|
|
348
|
-
}
|
|
349
|
-
})
|
|
350
|
-
})
|