How to calculate the scale's result?
<p>I am new to d3.js library, and I am trying to understand the concept of domain and ranges.</p>

<p>I read <a href="http://chimera.labs.oreilly.com/books/1230000000345/ch07.html#_creating_a_scale" rel="nofollow noreferrer">Scott Murray's book</a>, but I don't know how to calculate it.</p>

<p>I have this:</p>

<pre><code>var scale = d3.scale.linear()
    .domain([100, 500])
    .range([10, 350]);

scale(100);  //Returns 10
scale(300);  //Returns 180
scale(500);  //Returns 350
</code></pre>

<p>I know that 100 units of my input represent 10 in my output, and the same with 500 and 350... but why 180 is returned for 300 as input? How can I calculate this value?</p>

<p>I read <a href="https://www.dashingd3js.com/d3js-scales" rel="nofollow noreferrer">this tutorial</a> too, which explains how to calculate it, but when I follow the method, I don't get the same value, i.e., <code>scale(300)</code> doesn't return <code>180</code>.</p>

<p>Any idea why?</p>