chart = {
const data = d3.csvParse(await FileAttachment("alphabet.csv").text(), d3.autoType);
const y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.frequency)])
.range([height - margin.bottom, margin.top]);
const x = d3.scaleBand()
.domain(data.map(d => d.letter))
.rangeRound([margin.left, width - margin.right])
.padding(0.1);
const yTitle = g => g.append("text")
.attr("font-family", "sans-serif")
.attr("font-size", 10)
.attr("y", 10)
.text("↑ Frequency");
const yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y).ticks(null, "%"))
.call(g => g.select(".domain").remove());
const xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).tickSizeOuter(0));
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append('g')
.attr('fill', 'steelblue')
.selectAll('rect')
.data(data)
.join('rect')
.attr('x', d => x(d.letter))
.attr('y', d => y(d.frequency))
.attr('height', d => y(0) - y(d.frequency))
.attr('width', x.bandwidth());
svg.append("g")
.call(xAxis)
svg.append("g")
.call(yAxis);
svg.call(yTitle);
return svg.node();
}