UNPKG

@d3fc/d3fc-discontinuous-scale

Version:

A D3 scale that supports domains that are not continuous, allowing 'breaks' in the scale, for example skipping weekends for a date scale.

13 lines (12 loc) 537 B
export default function tickFilter(ticks, discontinuityProvider) { const discontinuousTicks = ticks.map(discontinuityProvider.clampUp); if ( discontinuousTicks.length !== new Set(discontinuousTicks.map(d => d?.valueOf())).size ) { console.warn( 'There are multiple ticks that fall within a discontinuity, which has led to them being rendered on top of each other. Consider using scale.ticks to explicitly specify the ticks for the scale.' ); } return discontinuousTicks; }