function stackDisperseX({ y, ...options }) {
const random = d3.randomUniform.source(d3.randomLcg(41))(0.1, 1 - 0.1);
const [x, setX] = Plot.column("x");
options = { ...Plot.stackX(options), x, y };
return Plot.transform(options, function (data, facets) {
options.transform(data, facets);
const X1 = options.x1.transform();
const X2 = options.x2.transform();
const N = Plot.valueof(data, options.repeat);
data = { length: d3.sum(N) };
const X = new Float32Array(data.length);
setX(X);
let k = 0;
facets = facets.map((facet) => {
const index = [];
for (const i of facet) {
const interval = d3.interpolate(X1[i], X2[i]);
for (let j = 0; j < N[i]; j++) {
X[k] = interval(random());
index.push(k);
k++;
}
}
return index;
});
return { data, facets };
});
}