chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const bar = svg.append("g").attr("fill", color).selectAll("rect").data(data);
bar
.join("rect")
.attr("x", (d, i) => x(i))
.attr("y", d => y(d.minutes))
.attr("height", d => y(0) - y(d.minutes))
.attr("width", x.bandwidth());
bar
.join("text")
.text((d) => `${d.homeOrAway === 'home' ? '' : '@'}${d.oppTeam}`)
.attr("x", function (d, i) {
return x(i) + x.bandwidth() / 2;
})
.attr("y", (d) => height - margin.bottom - 15)
.attr("fill", "white")
.attr("font-size", "18px")
.style("text-anchor", "middle");
bar
.join("text")
.text((d) => d.minutes)
.attr("x", function (d, i) {
return x(i) + x.bandwidth() / 2;
})
.attr("y", (d) => y(d.minutes) + 25)
.attr("fill", "white")
.attr("font-size", "18px")
.style("text-anchor", "middle");
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
return svg.node();
}