waveform-analysis 0.1.63 → 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.
Files changed (83) hide show
  1. package/README.md +9 -2
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +953 -946
  4. package/dist/style.css +1 -1
  5. package/dist/types/types/chart.d.ts +2 -1
  6. package/package.json +1 -1
  7. package/src/components/WaveformChart.vue +1 -1
  8. package/src/components/core/xDomain.ts +26 -2
  9. package/src/components/rendering/WaveformLegend.vue +1 -1
  10. package/src/components/rendering/WaveformSeriesLayer.vue +1 -1
  11. package/src/demo/DemoChartHost.vue +1 -0
  12. package/src/types/chart.ts +2 -1
  13. package/src/App.test.ts +0 -400
  14. package/src/components/annotation/components.test.ts +0 -372
  15. package/src/components/annotation/markup.test.ts +0 -371
  16. package/src/components/annotation/serialization.test.ts +0 -114
  17. package/src/components/core/constants.test.ts +0 -29
  18. package/src/components/core/fixedYDomainLayout.test.ts +0 -204
  19. package/src/components/core/grid.test.ts +0 -197
  20. package/src/components/core/latestTaskScheduler.test.ts +0 -51
  21. package/src/components/core/layout.test.ts +0 -373
  22. package/src/components/core/title.test.ts +0 -76
  23. package/src/components/core/useWaveformData.test.ts +0 -95
  24. package/src/components/core/useWaveformRenderSampling.test.ts +0 -17
  25. package/src/components/core/xDomain.test.ts +0 -28
  26. package/src/components/core/yAxisNice.test.ts +0 -174
  27. package/src/components/core/yAxisSlotLayout.test.ts +0 -165
  28. package/src/components/core/yDomain.test.ts +0 -56
  29. package/src/components/interaction/WaveformTooltip.test.ts +0 -276
  30. package/src/components/interaction/viewportInteractionState.test.ts +0 -101
  31. package/src/components/utils/useAnimationFrameThrottle.test.ts +0 -53
  32. package/src/components/waveformChartCases/annotationEditingAndReprojection.test.ts +0 -257
  33. package/src/components/waveformChartCases/compactAndSharedHover.test.ts +0 -358
  34. package/src/components/waveformChartCases/dataAndHoverPerformance.test.ts +0 -358
  35. package/src/components/waveformChartCases/dataLifecycle.test.ts +0 -310
  36. package/src/components/waveformChartCases/frameGridAndFormatting.test.ts +0 -389
  37. package/src/components/waveformChartCases/gridFill.test.ts +0 -95
  38. package/src/components/waveformChartCases/incompleteDataHover.test.ts +0 -155
  39. package/src/components/waveformChartCases/interactionAndAnnotationCreation.test.ts +0 -328
  40. package/src/components/waveformChartCases/layoutAndDomains.test.ts +0 -371
  41. package/src/components/waveformChartCases/legendVisibility.test.ts +0 -350
  42. package/src/components/waveformChartCases/multiAxisAndPagination.test.ts +0 -400
  43. package/src/components/waveformChartCases/multiAxisLabelAlignment.test.ts +0 -61
  44. package/src/components/waveformChartCases/presentationAndAxes.test.ts +0 -345
  45. package/src/components/waveformChartCases/presentationMode.test.ts +0 -327
  46. package/src/components/waveformChartCases/renderingStyles.test.ts +0 -283
  47. package/src/components/waveformChartCases/sizingAndTitles.test.ts +0 -370
  48. package/src/components/waveformChartCases/trackOrder.test.ts +0 -323
  49. package/src/components/waveformChartCases/viewportBoxAndPan.test.ts +0 -365
  50. package/src/components/waveformChartCases/viewportConstraintsAndReset.test.ts +0 -311
  51. package/src/components/waveformChartCases/viewportLifecycle.test.ts +0 -132
  52. package/src/components/waveformChartCases/viewportReset.test.ts +0 -251
  53. package/src/components/waveformChartCases/wheelZoomOut.test.ts +0 -114
  54. package/src/components/waveformChartCases/workerSamplingIntegration.test.ts +0 -117
  55. package/src/components/waveformChartCases/xDomainStrategy.test.ts +0 -168
  56. package/src/components/waveformChartCases/yAxisLayout.test.ts +0 -103
  57. package/src/components/waveformChartCases/zoomIntentAndDataRebind.test.ts +0 -213
  58. package/src/components/waveformChartCases/zoomPointConstraints.test.ts +0 -308
  59. package/src/components/waveformLegendGeometry.test.ts +0 -21
  60. package/src/components/waveformNormalization.test.ts +0 -170
  61. package/src/core/data.test.ts +0 -241
  62. package/src/core/rendering.test.ts +0 -267
  63. package/src/core/renderingStrategies.test.ts +0 -90
  64. package/src/core/samplingReference.test.ts +0 -124
  65. package/src/core/wasmSampling.test.ts +0 -205
  66. package/src/core/workerSampling/multiresolution.test.ts +0 -69
  67. package/src/core/workerSampling/protocol.test.ts +0 -34
  68. package/src/core/workerSampling/repository.test.ts +0 -400
  69. package/src/core/workerSampling/repositoryCache.test.ts +0 -163
  70. package/src/core/workerSampling/repositorySampling.test.ts +0 -106
  71. package/src/core/workerSampling/repositoryTypedDataset.test.ts +0 -89
  72. package/src/core/workerSampling/repositoryWasmDataset.test.ts +0 -70
  73. package/src/data/simulatedWaveforms.test.ts +0 -60
  74. package/src/demo/plotMarginControls.test.ts +0 -29
  75. package/src/demo/xAxisLabelControls.test.ts +0 -86
  76. package/src/test/setup.ts +0 -82
  77. package/src/test/waveformChart.ts +0 -75
  78. package/src/utils/domain.test.ts +0 -28
  79. package/src/utils/formatters.test.ts +0 -131
  80. package/src/utils/sampling.test.ts +0 -226
  81. package/src/views/FixedYDomainDemo.test.ts +0 -44
  82. package/src/views/WasmSamplingDemo.test.ts +0 -13
  83. package/src/views/wasmSamplingDemoSampling.test.ts +0 -27
@@ -1,358 +0,0 @@
1
- import { flushPromises } from '@vue/test-utils'
2
- import { describe, expect, it } from 'vitest'
3
-
4
- import { flushAnimationFrames } from '../../test/setup'
5
-
6
- import { gridSeries, mountSizedChart } from '../../test/waveformChart'
7
-
8
- describe('WaveformChart', () => {
9
- it('shows Y-axis end values only on the top row in compact mode', async () => {
10
- const wrapper = await mountSizedChart(
11
- {
12
- kind: 'series',
13
- series: [
14
- {
15
- name: 'top-left',
16
- data: {
17
- kind: 'points',
18
- points: [
19
- { x: 0, y: 0.11 },
20
- { x: 1, y: 0.89 },
21
- ],
22
- },
23
- },
24
- {
25
- name: 'top-right',
26
- data: {
27
- kind: 'points',
28
- points: [
29
- { x: 0, y: 1.11 },
30
- { x: 1, y: 1.89 },
31
- ],
32
- },
33
- },
34
- {
35
- name: 'bottom-left',
36
- data: {
37
- kind: 'points',
38
- points: [
39
- { x: 0, y: 2 },
40
- { x: 1, y: 3 },
41
- ],
42
- },
43
- },
44
- {
45
- name: 'bottom-right',
46
- data: {
47
- kind: 'points',
48
- points: [
49
- { x: 0, y: 4 },
50
- { x: 1, y: 5 },
51
- ],
52
- },
53
- },
54
- ],
55
- },
56
- { displayMode: 'compact', grid: { rowCount: 2, columnCount: 2 } },
57
- )
58
-
59
- const tracks = wrapper.findAll('.waveform-chart__track')
60
- const endTicks = tracks.map((track) =>
61
- track.findAll('.waveform-chart__axis--y .tick').filter((tick) => {
62
- const match = tick.attributes('transform')?.match(/translate\(0,\s*([\d.]+)\)/)
63
- return match ? Math.abs(Number(match[1])) <= 1 : false
64
- }),
65
- )
66
-
67
- expect(endTicks[0]).toHaveLength(1)
68
- expect(Number(endTicks[0][0].text())).toBe(1)
69
- expect(endTicks[1]).toHaveLength(1)
70
- expect(Number(endTicks[1][0].text())).toBe(2)
71
- expect(endTicks[2]).toHaveLength(0)
72
- expect(endTicks[3]).toHaveLength(0)
73
- })
74
-
75
- it('removes the later compact row top tick when the Y-axis end has a floating-point tail', async () => {
76
- const yDomain: [number, number] = [-1, 0.2]
77
- const calculatedAxisEnd = yDomain[0] + ((yDomain[1] - yDomain[0]) * 4) / 4
78
- expect(calculatedAxisEnd).not.toBe(yDomain[1])
79
-
80
- const wrapper = await mountSizedChart(
81
- {
82
- kind: 'series',
83
- series: [
84
- {
85
- name: 'top',
86
- data: {
87
- kind: 'points',
88
- points: [
89
- { x: 0, y: -0.8 },
90
- { x: 1, y: 0.1 },
91
- ],
92
- },
93
- },
94
- {
95
- name: 'bottom',
96
- data: {
97
- kind: 'points',
98
- points: [
99
- { x: 0, y: -0.7 },
100
- { x: 1, y: 0 },
101
- ],
102
- },
103
- },
104
- ],
105
- },
106
- { displayMode: 'compact', grid: { rowCount: 2, columnCount: 1 }, yDomain },
107
- )
108
-
109
- const [topTrack, bottomTrack] = wrapper.findAll('.waveform-chart__track')
110
- const ticksAt = (track: typeof topTrack, position: number) =>
111
- track.findAll('.waveform-chart__axis--y .tick').filter((tick) => {
112
- const match = tick.attributes('transform')?.match(/translate\(0,\s*([\d.]+)\)/)
113
- return match ? Math.abs(Number(match[1]) - position) <= 1 : false
114
- })
115
- const topTrackHeight = Number(topTrack.attributes('data-track-height'))
116
-
117
- expect(ticksAt(topTrack, 0)).toHaveLength(1)
118
- expect(ticksAt(topTrack, 0)[0].text()).toBe('0.2')
119
- expect(ticksAt(bottomTrack, 0)).toHaveLength(0)
120
- expect(Number(bottomTrack.attributes('data-track-top'))).toBeCloseTo(
121
- Number(topTrack.attributes('data-track-top')) + topTrackHeight,
122
- 6,
123
- )
124
-
125
- const boundaryLabels = [...ticksAt(topTrack, topTrackHeight), ...ticksAt(bottomTrack, 0)]
126
- expect(boundaryLabels).toHaveLength(1)
127
- })
128
-
129
- it('prefixes one shared exponent to the largest visible tick on every compact Y axis', async () => {
130
- const wrapper = await mountSizedChart(
131
- {
132
- kind: 'series',
133
- series: [
134
- {
135
- name: 'large',
136
- data: {
137
- kind: 'points',
138
- points: [
139
- { x: 0, y: 0 },
140
- { x: 1, y: 2540 },
141
- ],
142
- },
143
- },
144
- {
145
- name: 'tiny',
146
- data: {
147
- kind: 'points',
148
- points: [
149
- { x: 0, y: 0 },
150
- { x: 1, y: 0.0002 },
151
- ],
152
- },
153
- },
154
- ],
155
- },
156
- { displayMode: 'compact' },
157
- )
158
-
159
- const axes = wrapper.findAll('.waveform-chart__axis--y')
160
- expect(axes).toHaveLength(2)
161
- axes.forEach((axis, index) => {
162
- const labels = axis.findAll('.tick text').map((tick) => tick.text())
163
- const exponentLabels = labels.filter((label) => label.startsWith('E'))
164
- expect(exponentLabels).toHaveLength(1)
165
- expect(exponentLabels[0]).toMatch(index === 0 ? /^E\+03 / : /^E-04 /)
166
- })
167
- expect(wrapper.find('.waveform-chart__axis-exponent--y').exists()).toBe(false)
168
- })
169
-
170
- it('prefers a trimmed series name and falls back to yLabel for unnamed data', async () => {
171
- const namedChart = await mountSizedChart(
172
- {
173
- kind: 'series',
174
- series: [
175
- {
176
- name: ' BT2_2M ',
177
- unit: 'T',
178
- data: { kind: 'points', points: [{ x: 0, y: 1 }] },
179
- },
180
- ],
181
- },
182
- { yLabel: 'T' },
183
- )
184
- const unnamedChart = await mountSizedChart(
185
- { kind: 'points', points: [{ x: 0, y: 1 }] },
186
- { yLabel: '自定义幅值' },
187
- )
188
-
189
- expect(namedChart.get('.waveform-chart__y-axis-label').text()).toBe('BT2_2M')
190
- expect(unnamedChart.get('.waveform-chart__y-axis-label').text()).toBe('自定义幅值')
191
- })
192
-
193
- it('synchronizes every channel tooltip in separated mode and preserves the legacy event', async () => {
194
- const wrapper = await mountSizedChart(
195
- {
196
- kind: 'series',
197
- series: [
198
- {
199
- name: 'BT2_2M',
200
- unit: 'T',
201
- data: {
202
- kind: 'points',
203
- points: [
204
- { x: 0, y: 1 },
205
- { x: 1, y: 2 },
206
- ],
207
- },
208
- },
209
- {
210
- name: 'BT1_2M',
211
- unit: 'T',
212
- data: {
213
- kind: 'points',
214
- points: [
215
- { x: 0, y: 3 },
216
- { x: 1, y: 4 },
217
- ],
218
- },
219
- },
220
- ],
221
- },
222
- { displayMode: 'separated' },
223
- )
224
- const overlay = wrapper.get('.waveform-chart__overlay--shared')
225
- Object.defineProperty(overlay.element, 'getBoundingClientRect', {
226
- value: () => ({ left: 0, top: 0, width: 712, height: 290 }),
227
- })
228
-
229
- overlay.element.dispatchEvent(
230
- new MouseEvent('pointermove', { clientX: 700, clientY: 120, bubbles: true }),
231
- )
232
- flushAnimationFrames()
233
- await flushPromises()
234
-
235
- const tooltip = wrapper.get('.waveform-chart__tooltip')
236
- expect(tooltip.text()).toContain('未配置炮号: BT2_2M')
237
- expect(tooltip.text()).toContain('(x:1,000 y:2)')
238
- expect(tooltip.text()).toContain('未配置炮号: BT1_2M')
239
- expect(tooltip.text()).toContain('(x:1,000 y:4)')
240
- const crosshairLines = wrapper.findAll('.waveform-chart__crosshair line')
241
- expect(crosshairLines).toHaveLength(2)
242
- crosshairLines.forEach((line) => {
243
- expect(line.attributes('x1')).toBe(line.attributes('x2'))
244
- expect(line.attributes('y1')).toBe('0')
245
- })
246
- expect(wrapper.find('.waveform-chart__crosshair circle').exists()).toBe(false)
247
- expect(wrapper.emitted('point-hover')?.at(-1)).toEqual([{ x: 1, y: 2 }])
248
- })
249
-
250
- it('keeps synchronized hover feedback in compact mode', async () => {
251
- const wrapper = await mountSizedChart(gridSeries(2), { displayMode: 'compact' })
252
- const overlay = wrapper.get('.waveform-chart__overlay--shared')
253
- Object.defineProperty(overlay.element, 'getBoundingClientRect', {
254
- value: () => ({ left: 0, top: 0, width: 712, height: 290 }),
255
- })
256
-
257
- overlay.element.dispatchEvent(
258
- new MouseEvent('pointermove', { clientX: 700, clientY: 120, bubbles: true }),
259
- )
260
- flushAnimationFrames()
261
- await flushPromises()
262
-
263
- expect(wrapper.findAll('.waveform-chart__crosshair line')).toHaveLength(2)
264
- expect(wrapper.findAll('.waveform-chart__tooltip-series')).toHaveLength(2)
265
- expect(wrapper.emitted('point-hover')?.at(-1)).toEqual([{ x: 1, y: 1 }])
266
- })
267
-
268
- it('keeps separated tracks apart while sharing one x-axis and one interaction layer', async () => {
269
- const wrapper = await mountSizedChart(
270
- {
271
- kind: 'series',
272
- series: [
273
- {
274
- name: 'A',
275
- data: {
276
- kind: 'points',
277
- points: [
278
- { x: 0, y: 0 },
279
- { x: 2, y: 1 },
280
- ],
281
- },
282
- },
283
- {
284
- name: 'B',
285
- data: {
286
- kind: 'points',
287
- points: [
288
- { x: 0, y: 10 },
289
- { x: 2, y: 20 },
290
- ],
291
- },
292
- },
293
- ],
294
- },
295
- { displayMode: 'separated' },
296
- )
297
- const tracks = wrapper.findAll('.waveform-chart__track')
298
- const firstTop = Number(tracks[0].attributes('data-track-top'))
299
- const firstHeight = Number(tracks[0].attributes('data-track-height'))
300
- const secondTop = Number(tracks[1].attributes('data-track-top'))
301
-
302
- expect(wrapper.findAll('.waveform-chart__svg')).toHaveLength(1)
303
- expect(wrapper.findAll('.waveform-chart__axis--x')).toHaveLength(1)
304
- expect(wrapper.findAll('.waveform-chart__axis--y')).toHaveLength(2)
305
- expect(wrapper.findAll('.waveform-chart__y-axis-label').map((label) => label.text())).toEqual([
306
- 'A',
307
- 'B',
308
- ])
309
- expect(wrapper.findAll('.waveform-chart__overlay--shared')).toHaveLength(1)
310
- expect(secondTop).toBeGreaterThan(firstTop + firstHeight)
311
- })
312
-
313
- it('joins compact tracks without a gap and keeps only the bottom x-axis', async () => {
314
- const wrapper = await mountSizedChart(
315
- {
316
- kind: 'series',
317
- series: [
318
- {
319
- name: 'A',
320
- data: {
321
- kind: 'points',
322
- points: [
323
- { x: 0, y: -1 },
324
- { x: 1, y: 1 },
325
- ],
326
- },
327
- },
328
- {
329
- name: 'B',
330
- data: {
331
- kind: 'points',
332
- points: [
333
- { x: 0, y: 100 },
334
- { x: 1, y: 200 },
335
- ],
336
- },
337
- },
338
- ],
339
- },
340
- { displayMode: 'compact' },
341
- )
342
- const tracks = wrapper.findAll('.waveform-chart__track')
343
- const firstTop = Number(tracks[0].attributes('data-track-top'))
344
- const firstHeight = Number(tracks[0].attributes('data-track-height'))
345
- const secondTop = Number(tracks[1].attributes('data-track-top'))
346
-
347
- expect(wrapper.attributes('data-display-mode')).toBe('compact')
348
- expect(wrapper.findAll('.waveform-chart__axis--x')).toHaveLength(1)
349
- expect(wrapper.findAll('.waveform-chart__y-axis-label').map((label) => label.text())).toEqual([
350
- 'A',
351
- 'B',
352
- ])
353
- expect(secondTop).toBeCloseTo(firstTop + firstHeight, 6)
354
- expect(wrapper.findAll('.waveform-chart__axis--y')[0].text()).not.toBe(
355
- wrapper.findAll('.waveform-chart__axis--y')[1].text(),
356
- )
357
- })
358
- })