histogramVisualization = {
const x = d3
.scaleLinear()
.domain([0, 256])
.range([0 + margin, width - margin]);
const y = d3
.scaleLinear()
.domain([0, d3.max(histogram.map(x => d3.max(x.data)))])
.range([height - margin, 0 + margin]);
const area = d3
.area()
.x((_, i) => x(i))
.y0(y(0))
.y1((d, _) => y(d))
.curve(d3.curveStepAfter);
const svg = d3
.create("svg")
.attr("width", width)
.attr("height", height)
.attr("class", "histogram")
.style("background-color", "#333")
.style("isolation", "isolate");
for (const channel of histogram) {
svg
.append("path")
.attr("class", channel.name)
.attr("d", area([...channel.data, channel.data.slice(-1)]))
.attr("fill", channel.color)
.attr("stroke", channel.color)
.style("mix-blend-mode", "screen");
}
return svg.node();
}