waveform-analysis 0.1.47 → 0.1.48
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 +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +68 -62
- package/dist/types/components/core/layout.d.ts +2 -2
- package/dist/types/components/core/trackLayoutBuilder.d.ts +1 -0
- package/dist/types/types/chart.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/core/layout.ts +15 -6
- package/src/components/core/trackLayoutBuilder.ts +5 -2
- package/src/components/core/useWaveformLayout.ts +12 -6
- package/src/components/core/yAxisNice.test.ts +174 -0
- package/src/components/waveformChartCases/trackOrder.test.ts +130 -0
- package/src/demo/xAxisLabelControls.test.ts +1 -1
- package/src/types/chart.ts +2 -0
|
@@ -5,6 +5,32 @@ import { flushAnimationFrames } from '../../test/setup'
|
|
|
5
5
|
import { mountSizedChart } from '../../test/waveformChart'
|
|
6
6
|
|
|
7
7
|
describe('WaveformChart track order', () => {
|
|
8
|
+
const points = (offset: number) => ({
|
|
9
|
+
kind: 'points' as const,
|
|
10
|
+
points: [
|
|
11
|
+
{ x: 0, y: offset },
|
|
12
|
+
{ x: 1, y: offset + 1 },
|
|
13
|
+
],
|
|
14
|
+
})
|
|
15
|
+
const orderedSeries = (trackIds: string[]) => ({
|
|
16
|
+
kind: 'series' as const,
|
|
17
|
+
series: trackIds.map((trackId, index) => ({
|
|
18
|
+
id: trackId,
|
|
19
|
+
trackId,
|
|
20
|
+
name: trackId,
|
|
21
|
+
data: points(index + 1),
|
|
22
|
+
})),
|
|
23
|
+
})
|
|
24
|
+
const mergedFourTrackSeries = () => ({
|
|
25
|
+
kind: 'series' as const,
|
|
26
|
+
series: [
|
|
27
|
+
{ id: 'frame-1-a', trackId: 'frame-1', name: 'frame-1-a', data: points(1) },
|
|
28
|
+
{ id: 'frame-1-b', trackId: 'frame-1', name: 'frame-1-b', data: points(2) },
|
|
29
|
+
{ id: 'frame-3', trackId: 'frame-3', name: 'frame-3', data: points(3) },
|
|
30
|
+
{ id: 'frame-4', trackId: 'frame-4', name: 'frame-4', data: points(4) },
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
|
|
8
34
|
it('keeps a merged source slot empty without adding legend or tooltip data', async () => {
|
|
9
35
|
const wrapper = await mountSizedChart(
|
|
10
36
|
{
|
|
@@ -128,4 +154,108 @@ describe('WaveformChart track order', () => {
|
|
|
128
154
|
wrapper.findAll('.waveform-chart__track').map((track) => track.attributes('data-track-id')),
|
|
129
155
|
).toEqual(['frame-2', 'frame-1', 'later-a', 'later-b'])
|
|
130
156
|
})
|
|
157
|
+
|
|
158
|
+
it.each(['independent', 'separated', 'compact'] as const)(
|
|
159
|
+
'reclaims merged empty slots in %s mode when incomplete rows fill',
|
|
160
|
+
async (displayMode) => {
|
|
161
|
+
const wrapper = await mountSizedChart(mergedFourTrackSeries(), {
|
|
162
|
+
displayMode,
|
|
163
|
+
grid: {
|
|
164
|
+
rowCount: 4,
|
|
165
|
+
columnCount: 1,
|
|
166
|
+
fillIncompleteLastRow: true,
|
|
167
|
+
trackOrder: ['frame-1', 'frame-2', 'frame-3', 'frame-4'],
|
|
168
|
+
},
|
|
169
|
+
})
|
|
170
|
+
const tracks = wrapper.findAll('.waveform-chart__track')
|
|
171
|
+
const heights = tracks.map((track) => Number(track.attributes('data-track-height')))
|
|
172
|
+
|
|
173
|
+
expect(tracks.map((track) => track.attributes('data-track-id'))).toEqual([
|
|
174
|
+
'frame-1',
|
|
175
|
+
'frame-3',
|
|
176
|
+
'frame-4',
|
|
177
|
+
])
|
|
178
|
+
expect(wrapper.findAll('.waveform-chart__track--empty')).toHaveLength(0)
|
|
179
|
+
expect(wrapper.findAll('.waveform-chart__line')).toHaveLength(4)
|
|
180
|
+
expect(heights[0]).toBeCloseTo(heights[1] ?? Number.NaN)
|
|
181
|
+
expect(heights[1]).toBeCloseTo(heights[2] ?? Number.NaN)
|
|
182
|
+
expect(wrapper.findAll('.waveform-chart__legend')).toHaveLength(1)
|
|
183
|
+
expect(wrapper.get('.waveform-chart__legend').text()).not.toContain('frame-2')
|
|
184
|
+
},
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
it('reclaims only the current page without pulling tracks from the next page', async () => {
|
|
188
|
+
const wrapper = await mountSizedChart(
|
|
189
|
+
orderedSeries(['frame-1', 'frame-3', 'frame-4', 'frame-5', 'frame-6', 'frame-7', 'frame-8']),
|
|
190
|
+
{
|
|
191
|
+
grid: {
|
|
192
|
+
rowCount: 4,
|
|
193
|
+
columnCount: 1,
|
|
194
|
+
fillIncompleteLastRow: true,
|
|
195
|
+
trackOrder: [
|
|
196
|
+
'frame-1',
|
|
197
|
+
'frame-2',
|
|
198
|
+
'frame-3',
|
|
199
|
+
'frame-4',
|
|
200
|
+
'frame-5',
|
|
201
|
+
'frame-6',
|
|
202
|
+
'frame-7',
|
|
203
|
+
'frame-8',
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
)
|
|
208
|
+
const trackIds = () =>
|
|
209
|
+
wrapper.findAll('.waveform-chart__track').map((track) => track.attributes('data-track-id'))
|
|
210
|
+
|
|
211
|
+
expect(trackIds()).toEqual(['frame-1', 'frame-3', 'frame-4'])
|
|
212
|
+
await wrapper.get('.ant-pagination-next button').trigger('click')
|
|
213
|
+
expect(trackIds()).toEqual(['frame-5', 'frame-6', 'frame-7', 'frame-8'])
|
|
214
|
+
expect(wrapper.emitted('page-change')?.at(-1)).toEqual([2, 2])
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('retains ordered empty slots when incomplete rows do not fill', async () => {
|
|
218
|
+
const wrapper = await mountSizedChart(orderedSeries(['frame-1', 'frame-3', 'frame-4']), {
|
|
219
|
+
grid: {
|
|
220
|
+
rowCount: 4,
|
|
221
|
+
columnCount: 1,
|
|
222
|
+
fillIncompleteLastRow: false,
|
|
223
|
+
trackOrder: ['frame-1', 'frame-2', 'frame-3', 'frame-4'],
|
|
224
|
+
},
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
expect(
|
|
228
|
+
wrapper.findAll('.waveform-chart__track').map((track) => track.attributes('data-track-id')),
|
|
229
|
+
).toEqual(['frame-1', 'frame-2', 'frame-3', 'frame-4'])
|
|
230
|
+
expect(wrapper.findAll('.waveform-chart__track--empty')).toHaveLength(1)
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
it('keeps an entirely empty page addressable when incomplete rows fill', async () => {
|
|
234
|
+
const wrapper = await mountSizedChart(
|
|
235
|
+
orderedSeries(['frame-1', 'frame-2', 'frame-3', 'frame-4']),
|
|
236
|
+
{
|
|
237
|
+
grid: {
|
|
238
|
+
rowCount: 4,
|
|
239
|
+
columnCount: 1,
|
|
240
|
+
fillIncompleteLastRow: true,
|
|
241
|
+
trackOrder: [
|
|
242
|
+
'frame-1',
|
|
243
|
+
'frame-2',
|
|
244
|
+
'frame-3',
|
|
245
|
+
'frame-4',
|
|
246
|
+
'frame-5',
|
|
247
|
+
'frame-6',
|
|
248
|
+
'frame-7',
|
|
249
|
+
'frame-8',
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
await wrapper.get('.ant-pagination-next button').trigger('click')
|
|
256
|
+
|
|
257
|
+
expect(wrapper.findAll('.waveform-chart__track--empty')).toHaveLength(4)
|
|
258
|
+
expect(wrapper.emitted('page-change')?.at(-1)).toEqual([2, 2])
|
|
259
|
+
expect(wrapper.get('.ant-pagination-item-active').text()).toBe('2')
|
|
260
|
+
})
|
|
131
261
|
})
|
package/src/types/chart.ts
CHANGED
|
@@ -176,6 +176,8 @@ export interface WaveformAxesOptions {
|
|
|
176
176
|
lineVisible?: boolean
|
|
177
177
|
/** Target total number of equal Y-axis ticks, including endpoints. Defaults to 5. */
|
|
178
178
|
splitNumber?: number
|
|
179
|
+
/** Expands Y-axis domains to equal, human-friendly intervals. Defaults to true. */
|
|
180
|
+
nice?: boolean
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
|