colorContrast = ({ luminance = 60, ...options }) =>
Plot.initializer(options, (data, facets, channels, scales) => {
const contrast = (color) =>
d3.hcl(color).l > luminance ? "black" : "white";
return {
channels: {
fill: {
...channels.fill,
scale: undefined,
value:
channels.fill == null
|| scales.color == null
? Array.from(data).fill(contrast(options.fill))
: Array.from(channels.fill.value, (value) => contrast(scales.color(value)))
}
}
};
})