d3 / d3-array

Array manipulation, ordering, searching, summarizing, etc.

Home Page:https://d3js.org/d3-array

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple ticks generating from linear scale does not include domain

daBlesr opened this issue · comments

I have a linear scale with domain:
const linearScale = d3.scaleLinear().domain([-500000000, 2000000000]);

The ticks generator does not include the domain for a number of ticks between 8 and 17 inclusive:
linearScale.ticks(8) produces  [-400000000, -200000000, 0, 200000000, 400000000, 600000000, 800000000, 1000000000, 1200000000, 1400000000, 1600000000, 1800000000, 2000000000]
and linearScale.ticks(7) produces the correct  [-500000000, 0, 500000000, 1000000000, 1500000000, 2000000000].

This is somewhat unfortunate because now I have to loop over a range of desired number of ticks, till I can find an output where the domain is included.

d3-scale version 3.2.3
d3-array version 2.12.0
d3 version 6.6.0

You need to use scale.nice if you want the ticks to start and stop at the domain’s extent.