d3-scale icon indicating copy to clipboard operation
d3-scale copied to clipboard

Piecewise scales can result in tick collisions

Open ColinEberhardt opened this issue 5 years ago • 0 comments

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:

image

Should scales filter ticks if they collide?

ColinEberhardt avatar Sep 21 '20 14:09 ColinEberhardt