I didn't understand how scaleLinear works.
I know it's about a linear transformation like y = mx + b and I use it in this way:
const scale = scaleLinear().domain([0, 10]).range([0, 100])
but what are b, m and x in that case?
I didn't understand how scaleLinear works.
I know it's about a linear transformation like y = mx + b and I use it in this way:
const scale = scaleLinear().domain([0, 10]).range([0, 100])
but what are b, m and x in that case?
By specifying the domain and the range, you have two points:
So m = (y2 - y1) / (x2 - x1) and b = y1 - m * x1.
In your example from the comment:
const scale = scaleLinear().domain([0, 10]).range([0, 150])
m = 150 / 10 = 15 and b = 0 - 15 * 0 = 0