plain_bar_chart = function() {
let width = 300;
let height = 200;
function me(selection) {
const svg = selection
.append("svg")
.attr("width", width)
.attr("height", height)
.attr("font-family", "sans-serif")
.attr("font-size", "10")
.attr("text-anchor", "end");
const _x = d3
.scaleLinear()
.domain([0, d3.max(selection.datum())])
.range([0, width]);
const _y = d3
.scaleBand()
.domain(d3.range(selection.datum().length))
.range([0, height]);
const bar = svg
.selectAll("g")
.data(selection.datum())
.join("g")
.attr("transform", (d, i) => `translate(0,${_y(i)})`);
bar
.append("rect")
.attr("fill", "steelblue")
.attr("width", _x)
.attr("height", _y.bandwidth() - 1);
bar
.append("text")
.attr("fill", "white")
.attr("x", d => _x(d) - 3)
.attr("y", _y.bandwidth() / 2)
.attr("dy", "0.35em")
.text(d => d);
return me;
}
me.width = function(value) {
if (!arguments.length) return width;
width = value;
x.range([0, width]);
return me;
};
me.height = function(value) {
if (!arguments.length) return height;
height = value;
y.range([0, height]);
return me;
};
return me;
}