function occludeAxis({ axis, ...options } = {}) {
const orthogonalAxis = axis === "y" ? "x" : "y";
return Plot.initializer(
(axis === "y" ? Plot.dodgeX : Plot.dodgeY)(options),
(data, facets, channels, scales, dimensions, context) => {
console.log(typeof channels[orthogonalAxis].value);
const extent = (axis === "y" ? Math.min : Math.max)(
...channels[orthogonalAxis].value
);
const preservedIndices = channels[orthogonalAxis].value.reduce(
(acc, value, index) => (value === extent ? [...acc, index] : acc),
[]
);
const newChannels = Object.fromEntries(
Object.entries(channels).map(([key, { value, ...channel }]) => [
key,
{ ...channel, value: preservedIndices.map((index) => value[index]) }
])
);
return { data, facets, channels: newChannels };
}
);
}