d3-scale
d3-scale copied to clipboard
Piecewise scales can result in tick collisions
It's relatively common to see a scale that has a 'break' in it, allowing you to render outliers. You can achieve this effect with a piecewise scale that collapses a section of the domain.
For example, this will remove the section of the scale from 50-75:
svg.append('g')
.attr('transform', 'translate(0, 60)')
.call(sel => {
const scale = d3
.scaleLinear()
.domain([0, 50, 75, 100])
.range([0, 400, 400, 600]);
d3.axisBottom(scale)(sel);
});
However, when rendered with an axis, the ticks pile up as follows:

Should scales filter ticks if they collide?