function OptionStatsChart(data, prop, h) {
let height = h,
m = 25,
ref = DOM.svg(width, height);
let yScale = d3
.scaleLinear()
.domain(d3.extent(data.map(x => x[prop])))
.range([height - m, m]);
let xScale = d3
.scaleBand()
.domain(data.map(x => +x.DT))
.range([m, width - m])
.padding(0.1);
let svg = d3.select(ref).attr('viewBox', [-m, 0, width, height]);
svg.call(g => {
g.append('g')
.attr('class', 'xAxis')
.call(
d3
.axisBottom(xScale)
.ticks([...xScale.domain()])
.tickFormat(d3.timeFormat('%d/%-m'))
)
.call(g2 =>
g2
.attr('transform', `translate(0,${height - m})`)
.select('.domain')
.remove()
);
g.append('g')
.attr('class', 'yAxis')
.call(
d3
.axisLeft(yScale)
.ticks(3)
.tickFormat(d3.format(',.2s'))
)
.call(g2 => {
g2.attr('transform', `translate(${m},${0})`)
.select('.domain')
.remove();
g2.append('text')
.style('font-weight', '900')
.attr('font-size', h / 3)
.attr('transform', d => `${movement}`)
.text(() =>
prop
.split('_')
.join(' ')
.toUpperCase()
)
.attr('text-anchor', 'middle')
.attr('fill', 'black')
.attr('opacity', 0.5)
.clone(true)
.attr('stroke', 'white')
.attr('stroke-width', 2)
.attr('fill', 'none')
.attr('opacity', 0.7);
});
});
svg
.selectAll('.bar')
.data(data, d => +d.DT)
.join('rect')
.attr('class', 'bar')
.attr('x', d => xScale(+d.DT))
.attr('y', d => height - yScale(d[prop]) - m)
.attr('height', d => yScale(d[prop]))
.attr('width', xScale.bandwidth())
.attr('stroke', 'black')
.attr('fill', 'black')
.style('mix-blend-mode', 'overlay');
return ref;
}