Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4268a64de2 | ||
|
|
df77715994 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "waveform-analysis",
|
"name": "waveform-analysis",
|
||||||
"version": "0.1.42",
|
"version": "0.1.43",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
"module": "./dist/index.js",
|
"module": "./dist/index.js",
|
||||||
"types": "./dist/types/index.d.ts",
|
"types": "./dist/types/index.d.ts",
|
||||||
|
|||||||
@@ -135,9 +135,7 @@ export function buildTrackLayouts(options: BuildTrackLayoutsOptions): TrackLayou
|
|||||||
(_, index) => axisStart + ((axisEnd - axisStart) * index) / (tickCount - 1),
|
(_, index) => axisStart + ((axisEnd - axisStart) * index) / (tickCount - 1),
|
||||||
)
|
)
|
||||||
const showAxisEnd = options.displayMode !== 'compact' || cell.row === 0
|
const showAxisEnd = options.displayMode !== 'compact' || cell.row === 0
|
||||||
const visibleMajorTicks = showAxisEnd
|
const visibleMajorTicks = showAxisEnd ? majorTicks : majorTicks.slice(0, -1)
|
||||||
? majorTicks
|
|
||||||
: majorTicks.filter((tick) => tick !== axisEnd)
|
|
||||||
const tickValues = visibleMajorTicks
|
const tickValues = visibleMajorTicks
|
||||||
const { tickTextWidth } = axisTextMetrics(
|
const { tickTextWidth } = axisTextMetrics(
|
||||||
scale.domain() as [number, number],
|
scale.domain() as [number, number],
|
||||||
|
|||||||
@@ -72,6 +72,49 @@ describe('WaveformChart', () => {
|
|||||||
expect(endTicks[3]).toHaveLength(0)
|
expect(endTicks[3]).toHaveLength(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('removes the later compact row top tick when the Y-axis end has a floating-point tail', async () => {
|
||||||
|
const yDomain: [number, number] = [-1, 0.2]
|
||||||
|
const calculatedAxisEnd =
|
||||||
|
yDomain[0] + ((yDomain[1] - yDomain[0]) * 4) / 4
|
||||||
|
expect(calculatedAxisEnd).not.toBe(yDomain[1])
|
||||||
|
|
||||||
|
const wrapper = await mountSizedChart(
|
||||||
|
{
|
||||||
|
kind: 'series',
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: 'top',
|
||||||
|
data: { kind: 'points', points: [{ x: 0, y: -0.8 }, { x: 1, y: 0.1 }] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'bottom',
|
||||||
|
data: { kind: 'points', points: [{ x: 0, y: -0.7 }, { x: 1, y: 0 }] },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ displayMode: 'compact', grid: { rowCount: 2, columnCount: 1 }, yDomain },
|
||||||
|
)
|
||||||
|
|
||||||
|
const [topTrack, bottomTrack] = wrapper.findAll('.waveform-chart__track')
|
||||||
|
const ticksAt = (track: typeof topTrack, position: number) =>
|
||||||
|
track.findAll('.waveform-chart__axis--y .tick').filter((tick) => {
|
||||||
|
const match = tick.attributes('transform')?.match(/translate\(0,\s*([\d.]+)\)/)
|
||||||
|
return match ? Math.abs(Number(match[1]) - position) <= 1 : false
|
||||||
|
})
|
||||||
|
const topTrackHeight = Number(topTrack.attributes('data-track-height'))
|
||||||
|
|
||||||
|
expect(ticksAt(topTrack, 0)).toHaveLength(1)
|
||||||
|
expect(ticksAt(topTrack, 0)[0].text()).toBe('0.2')
|
||||||
|
expect(ticksAt(bottomTrack, 0)).toHaveLength(0)
|
||||||
|
expect(Number(bottomTrack.attributes('data-track-top'))).toBeCloseTo(
|
||||||
|
Number(topTrack.attributes('data-track-top')) + topTrackHeight,
|
||||||
|
6,
|
||||||
|
)
|
||||||
|
|
||||||
|
const boundaryLabels = [...ticksAt(topTrack, topTrackHeight), ...ticksAt(bottomTrack, 0)]
|
||||||
|
expect(boundaryLabels).toHaveLength(1)
|
||||||
|
})
|
||||||
|
|
||||||
it('prefixes one shared exponent to the largest visible tick on every compact Y axis', async () => {
|
it('prefixes one shared exponent to the largest visible tick on every compact Y axis', async () => {
|
||||||
const wrapper = await mountSizedChart(
|
const wrapper = await mountSizedChart(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user