Plot.initialize
A debugging routine, e.g.,
function Plot_initialize(data, {transform, ...channels} = {}) {
data = arrayify(data);
let index = data == null ? undefined : Uint32Array.from(data, (d, i) => i);
if (transform !== undefined) {
({facets: index, data} = transform(data, [index]));
if (index.length) ([index] = index);
}
return {
data,
index,
...Object.fromEntries(
Object.entries(channels)
.map(([name, value]) => [name, Plot.valueof(data, value)])
)
};
}
I think this is closer to what we want:
Plot.barY(data, Plot.groupX({x: "species"})).initialize()
Though, it could be made a little easier to inspect: you’d like to see both the Mark options and the channels.
Yes. Also would like a way to inspect what happens with faceting.
A version with faceting:
viewTransform = (data = [], {transform, ...channels}, facets = [Uint32Array.from(data, (d, i) => i)]) => {
if (transform !== undefined) {
({data, facets} = transform(data, facets));
}
return {
data,
facets,
...Object.fromEntries(
Object.entries(channels)
.map(([name, value]) => [name, Plot.valueof(data, value)])
)
};
}
(used in https://next.observablehq.com/d/61ca1967e419b882 with @enjalot)
I wrote up a notebook detailing how & why I want to use viewTransform in more depth:
https://observablehq.com/@enjalot/plot-spot
it also serves as a light "plugin" that could be used today to inspect and debug transforms. it's really just a rebrand of @fil's viewTransform
Here's an alternative / complementary approach, to read scales, dimensions, axes. https://observablehq.com/d/9e826c4659c798e8
I’m not really sure what, if anything, we want to do here.