Custom The Scale Function In D3.js
I would like to map 1-1000 to 1-190, my map function is: f(x) = { x if 1<=x and x<=100, 100 + (x-100)/10 if 100 < x <= 1000
Solution 1:
Finally, got the solution by tracing the source code:
d3.scale.linear().domain([1, 100, 1000]).range([1, 100,190]) //poly-linear
Solution 2:
I'm not familiar with 3d.js, but this is how I would do it in regular JS
function toNewScale( x ) {
return Math.round( x / 1000 * 190 );
}
if this is what you were asking.
Post a Comment for "Custom The Scale Function In D3.js"