function getHistogramOf(data, accessor, width=400, height=130) {
const values = data.map(accessor)
const marginBottom = 20
const boundedHeight = height - marginBottom
const marginLeft = 30
const boundedWidth = width - marginLeft
const xScale = d3.scaleLinear()
.domain(d3.extent(values)).nice()
.range([0, boundedWidth])
const bins = d3.histogram()
.domain(xScale.domain())
.thresholds(xScale.ticks(40))
(values)
const yScale = d3.scaleLinear()
.domain(d3.extent(bins, d => d.length)).nice()
.range([boundedHeight, 0])
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.style("overflow", "visible")
const bounds = svg.append("g")
.attr("transform", move(marginLeft))
const xAxis = g => g
.attr("transform", move(0, boundedHeight))
.call(
d3.axisBottom(xScale)
.tickValues([
d3.min(values),
d3.mean(values),
d3.max(values),
])
)
bounds.append("g")
.call(xAxis);
const yAxis = g => g
.call(d3.axisLeft(yScale).ticks(3))
bounds.append("g")
.call(yAxis);
const area = d3.area()
.defined(d => d)
.x(d => xScale(d["x0"]) + 1)
.y1(d => yScale(d.length))
.y0(boundedHeight)
bounds.append("path")
.datum(bins)
.attr("fill", "none")
.attr("fill", "cornflowerblue")
.attr("stroke-width", 1.5)
.attr("d", area);
return svg.node();
}