waveform-analysis 0.1.63 → 0.1.65

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 (97) hide show
  1. package/README.md +21 -5
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +986 -964
  4. package/dist/style.css +1 -1
  5. package/dist/types/components/core/constants.d.ts +1 -1
  6. package/dist/types/components/core/trackLayoutBuilder.d.ts +1 -0
  7. package/dist/types/components/core/yAxisConstants.d.ts +1 -1
  8. package/dist/types/types/chart.d.ts +6 -1
  9. package/package.json +1 -1
  10. package/src/App.vue +2 -2
  11. package/src/components/WaveformChart.css +4 -0
  12. package/src/components/WaveformChart.vue +2 -2
  13. package/src/components/core/constants.ts +3 -3
  14. package/src/components/core/layout.ts +1 -1
  15. package/src/components/core/trackLayoutBuilder.ts +42 -1
  16. package/src/components/core/useWaveformLayout.ts +2 -1
  17. package/src/components/core/useWaveformPresentation.ts +1 -1
  18. package/src/components/core/xDomain.ts +26 -2
  19. package/src/components/core/yAxisConstants.ts +1 -1
  20. package/src/components/rendering/WaveformLegend.vue +1 -1
  21. package/src/components/rendering/WaveformSeriesLayer.vue +1 -1
  22. package/src/components/rendering/WaveformTrack.css +5 -2
  23. package/src/components/rendering/WaveformTrack.vue +7 -1
  24. package/src/components/rendering/WaveformTrackAxes.vue +8 -2
  25. package/src/demo/DemoChartHost.vue +1 -0
  26. package/src/types/chart.ts +6 -1
  27. package/src/App.test.ts +0 -400
  28. package/src/components/annotation/components.test.ts +0 -372
  29. package/src/components/annotation/markup.test.ts +0 -371
  30. package/src/components/annotation/serialization.test.ts +0 -114
  31. package/src/components/core/constants.test.ts +0 -29
  32. package/src/components/core/fixedYDomainLayout.test.ts +0 -204
  33. package/src/components/core/grid.test.ts +0 -197
  34. package/src/components/core/latestTaskScheduler.test.ts +0 -51
  35. package/src/components/core/layout.test.ts +0 -373
  36. package/src/components/core/title.test.ts +0 -76
  37. package/src/components/core/useWaveformData.test.ts +0 -95
  38. package/src/components/core/useWaveformRenderSampling.test.ts +0 -17
  39. package/src/components/core/xDomain.test.ts +0 -28
  40. package/src/components/core/yAxisNice.test.ts +0 -174
  41. package/src/components/core/yAxisSlotLayout.test.ts +0 -165
  42. package/src/components/core/yDomain.test.ts +0 -56
  43. package/src/components/interaction/WaveformTooltip.test.ts +0 -276
  44. package/src/components/interaction/viewportInteractionState.test.ts +0 -101
  45. package/src/components/utils/useAnimationFrameThrottle.test.ts +0 -53
  46. package/src/components/waveformChartCases/annotationEditingAndReprojection.test.ts +0 -257
  47. package/src/components/waveformChartCases/compactAndSharedHover.test.ts +0 -358
  48. package/src/components/waveformChartCases/dataAndHoverPerformance.test.ts +0 -358
  49. package/src/components/waveformChartCases/dataLifecycle.test.ts +0 -310
  50. package/src/components/waveformChartCases/frameGridAndFormatting.test.ts +0 -389
  51. package/src/components/waveformChartCases/gridFill.test.ts +0 -95
  52. package/src/components/waveformChartCases/incompleteDataHover.test.ts +0 -155
  53. package/src/components/waveformChartCases/interactionAndAnnotationCreation.test.ts +0 -328
  54. package/src/components/waveformChartCases/layoutAndDomains.test.ts +0 -371
  55. package/src/components/waveformChartCases/legendVisibility.test.ts +0 -350
  56. package/src/components/waveformChartCases/multiAxisAndPagination.test.ts +0 -400
  57. package/src/components/waveformChartCases/multiAxisLabelAlignment.test.ts +0 -61
  58. package/src/components/waveformChartCases/presentationAndAxes.test.ts +0 -345
  59. package/src/components/waveformChartCases/presentationMode.test.ts +0 -327
  60. package/src/components/waveformChartCases/renderingStyles.test.ts +0 -283
  61. package/src/components/waveformChartCases/sizingAndTitles.test.ts +0 -370
  62. package/src/components/waveformChartCases/trackOrder.test.ts +0 -323
  63. package/src/components/waveformChartCases/viewportBoxAndPan.test.ts +0 -365
  64. package/src/components/waveformChartCases/viewportConstraintsAndReset.test.ts +0 -311
  65. package/src/components/waveformChartCases/viewportLifecycle.test.ts +0 -132
  66. package/src/components/waveformChartCases/viewportReset.test.ts +0 -251
  67. package/src/components/waveformChartCases/wheelZoomOut.test.ts +0 -114
  68. package/src/components/waveformChartCases/workerSamplingIntegration.test.ts +0 -117
  69. package/src/components/waveformChartCases/xDomainStrategy.test.ts +0 -168
  70. package/src/components/waveformChartCases/yAxisLayout.test.ts +0 -103
  71. package/src/components/waveformChartCases/zoomIntentAndDataRebind.test.ts +0 -213
  72. package/src/components/waveformChartCases/zoomPointConstraints.test.ts +0 -308
  73. package/src/components/waveformLegendGeometry.test.ts +0 -21
  74. package/src/components/waveformNormalization.test.ts +0 -170
  75. package/src/core/data.test.ts +0 -241
  76. package/src/core/rendering.test.ts +0 -267
  77. package/src/core/renderingStrategies.test.ts +0 -90
  78. package/src/core/samplingReference.test.ts +0 -124
  79. package/src/core/wasmSampling.test.ts +0 -205
  80. package/src/core/workerSampling/multiresolution.test.ts +0 -69
  81. package/src/core/workerSampling/protocol.test.ts +0 -34
  82. package/src/core/workerSampling/repository.test.ts +0 -400
  83. package/src/core/workerSampling/repositoryCache.test.ts +0 -163
  84. package/src/core/workerSampling/repositorySampling.test.ts +0 -106
  85. package/src/core/workerSampling/repositoryTypedDataset.test.ts +0 -89
  86. package/src/core/workerSampling/repositoryWasmDataset.test.ts +0 -70
  87. package/src/data/simulatedWaveforms.test.ts +0 -60
  88. package/src/demo/plotMarginControls.test.ts +0 -29
  89. package/src/demo/xAxisLabelControls.test.ts +0 -86
  90. package/src/test/setup.ts +0 -82
  91. package/src/test/waveformChart.ts +0 -75
  92. package/src/utils/domain.test.ts +0 -28
  93. package/src/utils/formatters.test.ts +0 -131
  94. package/src/utils/sampling.test.ts +0 -226
  95. package/src/views/FixedYDomainDemo.test.ts +0 -44
  96. package/src/views/WasmSamplingDemo.test.ts +0 -13
  97. 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
- })