chart = {
const width = 400;
const height = 200;
const marginTop = 30;
const marginRight = 30;
const marginBottom = 70;
const marginLeft = 80;
const x = d3.scaleBand()
.domain(avgMetascoreByPlatform.map(d => d.platform))
.range([marginLeft, width - marginRight])
.padding(0.1);
const y = d3.scaleLinear()
.domain([93, d3.max(avgMetascoreByPlatform, d => d.avgMetascore)]).nice()
.range([height - marginBottom, marginTop]);
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.selectAll("rect")
.data(avgMetascoreByPlatform)
.join("rect")
.attr("x", d => x(d.platform))
.attr("y", d => y(d.avgMetascore))
.attr("height", d => y(93) - y(d.avgMetascore))
.attr("width", x.bandwidth())
.attr("fill", "steelblue");
svg.append("g")
.attr("transform", `translate(0,${height - marginBottom})`)
.call(d3.axisBottom(x))
.selectAll("text")
.attr("transform", "rotate(-45)")
.style("text-anchor", "end")
.style("font-size", "6px");
svg.append("text")
.attr("x", (width + marginLeft - marginRight)/2)
.attr("y", height - 10)
.attr("text-anchor", "middle")
.style("font-size", "12px")
.text("Platform");
svg.append("g")
.attr("transform", `translate(${marginLeft},0)`)
.call(d3.axisLeft(y))
.selectAll("text")
.style("font-size", "8px");
svg.append("text")
.attr("x", -(height/2) + 15)
.attr("y", 30)
.attr("text-anchor", "middle")
.style("font-size", "12px")
.attr("transform", "rotate(-90)")
.text("Average Metascore");
return svg.node();
}