bar = {
const width = 800;
const height = 200;
const margin = ({top: 0, right: 20, bottom: 20, left: 20})
const axisColor = "#404040"
const svg = d3.create("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom);
const x = d3.scaleBand()
.domain(df.map(d => d.year))
.range([margin.left, width])
.padding(0.2)
const y = d3.scaleLinear()
.domain([0, d3.max(df, d => d.population)])
.range([height, margin.top])
const xAxisGroup = svg.append("g")
.attr("transform", `translate(0,${height})`)
.call(d3.axisBottom(x))
.attr("color", axisColor);
xAxisGroup.append("text")
.attr("x", width / 2)
.attr("y", margin.bottom - 5)
.attr("text-anchor", "middle")
.attr("font-size", 10)
.attr("font-family", "sans-serif")
.text("Year");
const yAxisGroup = svg.append("g")
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.attr("color", axisColor);
yAxisGroup.append("text")
.attr("x", -margin.left)
.attr("y", height / 2)
.attr("text-anchor", "middle")
.attr("font-size", 10)
.attr("font-family", "sans-serif")
.text("Population");
svg.append("g")
.attr("id", "bars")
.selectAll('rect')
.data(df)
.join("rect")
.attr("width", x.bandwidth())
.attr("height", d => height - y(d.population))
.attr("y", d => y(d.population))
.attr("x", d => x(d.year))
.attr("fill", "lightgray")
svg.append("g").attr("id", "annotation");
return svg.node()
}