drawComparisonChart = ele => {
const svg = ele
.append("svg")
.style("height", chart_height + "px")
.style("width", chart_width + "px");
svg.append("path")
.datum(d => d.values.filter(areaNeg.defined()))
.attr("fill", "white")
.attr("d", areaNeg)
svg.append("path")
.datum(d => d.values.filter(areaPos.defined()))
.attr("fill", "white")
.attr("d", areaPos)
svg.append("path")
.datum(d => d.values)
.attr("fill", d => '#05A0C4')
.style("opacity", .80)
.attr("d", d3.area()
.curve(d3.curveStep)
.x(d => x(timeParser(d.date)))
.y0(y(height))
.y1(d => y(Math.min(0,d.perc_change))))
svg.append("path")
.datum(d => d.values)
.attr("fill", 'white')
.attr("d", d3.area()
.curve(d3.curveStep)
.x(d => x(timeParser(d.date)))
.y0(y(height))
.y1(d => y(Math.max(0,d.perc_change))))
if (toggle) {
svg.append("path")
.data(by_type_data)
.datum(d => d.values)
.attr("stroke", "#F4A045")
.attr('stroke-width', 2)
.attr('stroke-opacity', 1)
.attr('fill', 'none')
.attr("d", d3.line()
.curve(d3.curveLinear)
.x(d => x(timeParser(d.date)))
.y(d => y(d.perc_change)))
}
svg.append("g").call(xAxis)
.select('.domain').remove();
svg.append("g").call(yAxis)
.select('.domain').remove();
svg.append('text').call(chartTitle);
svg.append('line')
.style('stroke', '#8D6A9F')
.style('stroke-width', 1)
.style('stroke-dasharray', '6,3')
.style('opacity', 0.7)
.attr("x1", x(timeParser("2020-03-19")))
.attr("y1", margin.top + 5)
.attr("x2", x(timeParser("2020-03-19")))
.attr("y2", 185)
svg.append('line')
.style('stroke', '#C4C4C4')
.style('stroke-width', .75)
.attr("x1", x(timeParser("2020-02-15")))
.attr("y1", margin.top + 5)
.attr("x2", x(timeParser("2020-02-15")))
.attr("y2", 185)
svg.append('line')
.style('stroke', '#C4C4C4')
.style('stroke-width', 0.75)
.attr("x1", x(timeParser('2020-02-15')))
.attr("y1", y(0))
.attr("x2", x(timeParser('2020-07-05')))
.attr("y2", y(0))
}