chart = {
const width = 500;
const height = 500;
const margin = { top: 20, right: 20, bottom: 30, left: 80 };
const svg = d3.select(DOM.svg(width, height));
const x = d3.scaleBand()
.domain(data.map(d => d.name))
.range([margin.left, width - margin.right])
.padding(0.1);
const y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.value)])
.nice()
.range([height - margin.bottom, margin.top]);
svg.append("g")
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", d => x(d.name))
.attr("y", y(0))
.attr("height", 0)
.attr("width", x.bandwidth())
.attr("fill", "steelblue")
.on("mouseover", function () {
d3.select(this).transition().duration(200).attr("fill", "orange");
})
.on("mouseout", function () {
d3.select(this).transition().duration(200).attr("fill", "steelblue");
})
.transition()
.duration(800)
.delay((d, i) => i * 100)
.attr("y", d => y(d.value))
.attr("height", d => y(0) - y(d.value));
svg.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x));
svg.append("g")
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y).tickFormat(d3.format(",")))
return svg.node();
}