function stereoHistogram(Plot) {
return function (data, options) {
const dot = Plot.rectY(data, options);
const { render } = dot;
dot.render = function (
I,
{},
{ x1: X1, x2: X2, y1: Y1, y2: Y2 },
{ marginLeft, marginTop, marginRight, marginBottom, width, height }
) {
width = (width - marginLeft - marginRight) | 0;
height = (height - marginTop - marginBottom) | 0;
const dpi = 1;
const context = DOM.context2d(width, height, dpi);
context.fillStyle = "#fff";
context.fillRect(0, 0, width, height);
context.fillStyle = "#000";
context.strokeStyle = "#333";
for (const i of I) {
context.fillRect(X1[i] + 5, Y2[i], X2[i] - X1[i] - 10, Y1[i] - Y2[i]);
context.strokeRect(X1[i] + 5, Y2[i], X2[i] - X1[i] - 10, Y1[i] - Y2[i]);
}
const imdata = context.getImageData(0, 0, dpi * width, dpi * height);
const pixels = context.getImageData(0, 0, dpi * width, dpi * height);
generatePixelData({
pixels,
imdata,
width: dpi * width,
height: dpi * height,
colors: Array.from(d3.schemeAccent.slice(0, 6), (c) => {
c = d3.rgb(c);
return [c.r, c.g, c.b, 255];
})
});
if (apply3d) context.putImageData(pixels, 0, 0);
return d3
.create("svg:image")
.attr("x", marginLeft)
.attr("y", marginTop)
.attr("image-rendering", "pixelated")
.attr("width", width)
.attr("height", height)
.attr("href", context.canvas.toDataURL())
.node();
};
return dot;
};
}