d3 unevenly distributed scaling

2019-07-16 04:18发布

问题:

any suggestions for drawing axes with unequal spacing between the values. For instance I am currently drawing axes using:

yScale = d3.scale.linear().domain([0, 60000]).range([height, 0])

I need more spacing between 0 and 5000 than distributing all the data points equally

回答1:

Try using a polylinear scale:

yScale = d3.scale.linear().domain([0, 5000, 60000]).range([height, height/2, 0])

The range (0, 5000) and (5000, 60000) will both be given the same amount of space.



标签: d3.js axes