@@ -224,40 +224,35 @@ class Voronoi extends Mark {
224
224
let { x : X , y : Y , z : Z } = channels ;
225
225
( { x : X , y : Y } = applyPosition ( channels , scales , context ) ) ;
226
226
Z = Z ?. value ;
227
- const C = new Array ( facets . length ) ;
227
+ const C = new Array ( ( X ?? Y ) . length ) . fill ( null ) ;
228
228
const [ cx , cy ] = applyFrameAnchor ( this , dimensions ) ;
229
229
const xi = X ? ( i ) => X [ i ] : constant ( cx ) ;
230
230
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 ) ;
237
236
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 ) ;
240
239
}
241
240
}
242
241
}
243
- return { data, facets, channels : { cells : { value : C , filter : null } } } ;
242
+ return { data, facets, channels : { cells : { value : C } } } ;
244
243
} ) ,
245
244
voronoiDefaults
246
245
) ;
247
246
}
248
247
render ( index , scales , channels , dimensions , context ) {
249
248
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 ;
255
250
return create ( "svg:g" , context )
256
251
. call ( applyIndirectStyles , this , dimensions , context )
257
252
. call ( applyTransform , this , { x : X && x , y : Y && y } )
258
253
. call ( ( g ) => {
259
254
g . selectAll ( )
260
- . data ( index . filter ( ( i ) => C [ i ] != null ) )
255
+ . data ( index )
261
256
. enter ( )
262
257
. append ( "path" )
263
258
. call ( applyDirectStyles , this )
0 commit comments