feat(chart): support fixed y-axis domains
All checks were successful
Package component / package (push) Successful in 9m22s
All checks were successful
Package component / package (push) Successful in 9m22s
This commit is contained in:
@@ -294,6 +294,31 @@ describe('WaveformChart', () => {
|
||||
expect(wrapper.get('.waveform-chart__axis-endpoint--end').text()).toBe('1.00')
|
||||
})
|
||||
|
||||
it('reacts to exact fixed Y-domain props and returns to automatic bounds', async () => {
|
||||
const wrapper = await mountSizedChart({
|
||||
kind: 'points',
|
||||
points: [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 1, y: 100 },
|
||||
],
|
||||
})
|
||||
const yTickLabels = () =>
|
||||
wrapper
|
||||
.get('.waveform-chart__axis--y')
|
||||
.findAll('.tick text')
|
||||
.map((tick) => tick.text())
|
||||
|
||||
await wrapper.setProps({ yDomain: [3, 97] })
|
||||
await flushPromises()
|
||||
expect(yTickLabels()).toContain('3.00')
|
||||
expect(yTickLabels()).toContain('97.00')
|
||||
|
||||
await wrapper.setProps({ yDomain: undefined })
|
||||
await flushPromises()
|
||||
expect(yTickLabels()).not.toContain('3.00')
|
||||
expect(yTickLabels()).not.toContain('97.00')
|
||||
})
|
||||
|
||||
it('keeps annotations bound to their channel while paging', async () => {
|
||||
const wrapper = await mountSizedChart(gridSeries(3), {
|
||||
grid: { rowCount: 1, columnCount: 1 },
|
||||
|
||||
@@ -224,6 +224,56 @@ describe('WaveformChart', () => {
|
||||
window.dispatchEvent(new KeyboardEvent('keyup', { code: 'Space' }))
|
||||
})
|
||||
|
||||
it('keeps a fixed Y domain through panning and viewport reset', async () => {
|
||||
const wrapper = await mountSizedChart(
|
||||
{
|
||||
kind: 'points',
|
||||
points: [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 1, y: 100 },
|
||||
],
|
||||
},
|
||||
{ pannable: true, yDomain: [3, 97] },
|
||||
)
|
||||
const overlay = wrapper.get('.waveform-chart__overlay--independent')
|
||||
const width = Number(overlay.attributes('width'))
|
||||
const height = Number(overlay.attributes('height'))
|
||||
Object.defineProperty(overlay.element, 'getBoundingClientRect', {
|
||||
value: () => ({ left: 0, top: 0, width, height }),
|
||||
})
|
||||
const yTickLabels = () =>
|
||||
wrapper
|
||||
.get('.waveform-chart__axis--y')
|
||||
.findAll('.tick text')
|
||||
.map((tick) => tick.text())
|
||||
const initialLabels = yTickLabels()
|
||||
|
||||
await wrapper.trigger('pointerenter')
|
||||
window.dispatchEvent(new KeyboardEvent('keydown', { code: 'Space', cancelable: true }))
|
||||
const down = new MouseEvent('pointerdown', {
|
||||
button: 0,
|
||||
clientX: width / 2,
|
||||
clientY: height / 2,
|
||||
bubbles: true,
|
||||
})
|
||||
Object.defineProperty(down, 'pointerId', { value: 34 })
|
||||
overlay.element.dispatchEvent(down)
|
||||
const move = new MouseEvent('pointermove', {
|
||||
clientX: width / 2 + 20,
|
||||
clientY: height / 2 + 40,
|
||||
bubbles: true,
|
||||
})
|
||||
Object.defineProperty(move, 'pointerId', { value: 34 })
|
||||
overlay.element.dispatchEvent(move)
|
||||
await flushPromises()
|
||||
|
||||
expect(yTickLabels()).toEqual(initialLabels)
|
||||
;(wrapper.vm as unknown as { resetViewport: () => void }).resetViewport()
|
||||
await flushPromises()
|
||||
expect(yTickLabels()).toEqual(initialLabels)
|
||||
window.dispatchEvent(new KeyboardEvent('keyup', { code: 'Space' }))
|
||||
})
|
||||
|
||||
it('does not activate pannable on a chart that the pointer is outside', async () => {
|
||||
const data: WaveformData = {
|
||||
kind: 'points',
|
||||
|
||||
Reference in New Issue
Block a user