Generate rainbow colors based on value
<p>I am trying to generate rainbow colors based on the numeric value.</p>

<pre><code>var max = 10000;
var min = 0;
var val = 8890;

function getcolor(min,max,val) {
     // return red - black;
 }
</code></pre>

<p><strong>colors</strong>
Red
Yellow
Green
Blue
Black (value == 0)</p>

<p>Like in the url <a href="http://i.stack.imgur.com/MRevs.jpg" rel="noreferrer">http://i.stack.imgur.com/MRevs.jpg</a></p>

<p>From the above values how to generate color between red - black. High value is red and low value is black.</p>