How to make a color gradient bar using d3js
<p>I'm trying to implement a a gradient bar using d3js, so by giving 2 colours I need to show the gradient colour starting from the first colour value and ending with the other colour value.</p>

<p>So it would look similar to this:</p>

<p><a href="https://i.stack.imgur.com/gS4ja.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gS4ja.png" alt="vertical gradient bar with numbers down the right hand side"></a></p>

<p>This is the legend for a scatterplot chart I'm implementing using hexagonal bins, where bins color indicates the frequency on each point. Since I'm building the data dynamically, I need to append this into another dynamically built SVG.</p>