plot
plot copied to clipboard
add BigInt support to the normalize transform
Note: it's a bit of a bummer in that we're adding overhead for all Arrays (by making a copy of the channel to a Float64Array). Maybe we could just do it if the first non-nullish value is BigInt?
cc: @juba
closes #2154
It should definitely be earlier — in my code we coerce the whole channel as many times as there are series. But where? Maybe as high as in the map transform, where we do https://github.com/observablehq/plot/blob/0032c11160e6340ce44307675d93bed382d10446/src/transforms/map.js#L36
In that case the mapper should possibly have a type key, like so:
{
mapIndex(I, S, T) {
const b = basis(I, S);
for (const i of I) {
T[i] = S[i] === null ? NaN : S[i] / b;
}
},
type: Float64Array
}
that would be passed as the third argument to valueof?
The alternative is (what you say) to preemptively convert all BigInt independently of where they're used.
This is very close to https://github.com/observablehq/plot/issues/473