Skip to content

Commit b67756a

Browse files
committed
facet reindexation to be handled separately (#1648)
1 parent 8076ef8 commit b67756a

File tree

3 files changed

+11
-1202
lines changed

3 files changed

+11
-1202
lines changed

src/marks/delaunay.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,40 +224,35 @@ class Voronoi extends Mark {
224224
let {x: X, y: Y, z: Z} = channels;
225225
({x: X, y: Y} = applyPosition(channels, scales, context));
226226
Z = Z?.value;
227-
const C = new Array(facets.length);
227+
const C = new Array((X ?? Y).length).fill(null);
228228
const [cx, cy] = applyFrameAnchor(this, dimensions);
229229
const xi = X ? (i) => X[i] : constant(cx);
230230
const yi = Y ? (i) => Y[i] : constant(cy);
231-
for (let [fi, facet] of facets.entries()) {
232-
if (X) facet = facet.filter((i) => defined(X[i]));
233-
if (Y) facet = facet.filter((i) => defined(Y[i]));
234-
const Cf = (C[fi] = []);
235-
for (const [, index] of maybeGroup(facet, Z)) {
236-
const delaunay = Delaunay.from(index, xi, yi);
231+
for (let I of facets) {
232+
if (X) I = I.filter((i) => defined(xi(i)));
233+
if (Y) I = I.filter((i) => defined(yi(i)));
234+
for (const [, J] of maybeGroup(I, Z)) {
235+
const delaunay = Delaunay.from(J, xi, yi);
237236
const voronoi = voronoiof(delaunay, dimensions);
238-
for (let i = 0, n = index.length; i < n; ++i) {
239-
Cf[index[i]] = voronoi.renderCell(i);
237+
for (let i = 0, n = J.length; i < n; ++i) {
238+
C[J[i]] = voronoi.renderCell(i);
240239
}
241240
}
242241
}
243-
return {data, facets, channels: {cells: {value: C, filter: null}}};
242+
return {data, facets, channels: {cells: {value: C}}};
244243
}),
245244
voronoiDefaults
246245
);
247246
}
248247
render(index, scales, channels, dimensions, context) {
249248
const {x, y} = scales;
250-
const {
251-
x: X,
252-
y: Y,
253-
cells: {[index.fi ?? 0]: C}
254-
} = channels;
249+
const {x: X, y: Y, cells: C} = channels;
255250
return create("svg:g", context)
256251
.call(applyIndirectStyles, this, dimensions, context)
257252
.call(applyTransform, this, {x: X && x, y: Y && y})
258253
.call((g) => {
259254
g.selectAll()
260-
.data(index.filter((i) => C[i] != null))
255+
.data(index)
261256
.enter()
262257
.append("path")
263258
.call(applyDirectStyles, this)

0 commit comments

Comments
 (0)