This is interesting to me. Look at the following D3 code:
var scale = d3.scale.linear()     .domain([100, 500])     .range([10, 350]);  scale(100);  //Returns 10 scale(300);  //Returns 180 scale(500);  //Returns 350   Is there a function that inverse of scale? For example,
inverseScale(10);   //Returns 100 inverseScale(180);  //Returns 300 inverseScale(350);  //Returns 500 
                D3 scale types D3 has around 12 different scale types (scaleLinear, scalePow, scaleQuantise, scaleOrdinal etc.) and broadly speaking they can be classified into 3 groups: scales with continuous input and continuous output. scales with continuous input and discrete output. scales with discrete input and discrete output.
The d3. scaleLinear() method is used to create a visual scale point. This method is used to transform data values into visual variables.
If input is greater than 10 or less than 0 in domain or the range is greater than 600 then it is not a valid scale in d3 js.
Yes, there is, and it's aptly named invert.
console.log(scale.invert(10));   //Returns 100 console.log(scale.invert(180));  //Returns 300 console.log(scale.invert(350));  //Returns 500 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With