This should display a chart in greyscale, by opting in the scale.
Note that it works when reduce is a string (reduce: "mode").
export async function reducerGroupScaleFunction() {
const penguins = await d3.csv<any>("data/penguins.csv", d3.autoType);
return Plot.plot({
color: {scheme: "greys"},
marks: [
Plot.barY(
penguins,
Plot.groupX(
{
y: "count",
fill: {
reduce: (index: number[], values: any[]) => d3.mode(index, (i) => values[i]),
scale: true // 🌶
}
},
{x: "species", fill: (d) => (d.island === "Biscoe" ? "orange" : "green"), fy: "sex"}
)
)
]
});
}
This should display a chart in greyscale, by opting in the scale.
Note that it works when reduce is a string (reduce: "mode").
(Seen in #1360)