'#c0392b' : '#03a678'; } }).attr('width', 1).attr('height', d => { return height - yVolumeScale(d['volume']); }); This section relies on your understanding of how the selectAll() method works with the enter() and append() methods.
svg.selectAll().data(volData).enter().append('rect').attr('x', d => { return xScale(d['date']); }).attr('y', d => { return yVolumeScale(d['volume']); }).attr('fill', (d, i) => { if (i === 0) { return '#03a678'; } else { return volData[i - 1].close > d.close?