@@ -226,41 +226,40 @@ class Voronoi extends Mark {
226
226
let { x : X , y : Y , z : Z } = channels ;
227
227
( { x : X , y : Y } = applyPosition ( channels , scales , context ) ) ;
228
228
Z = Z ?. value ;
229
- const C = new Array ( data . length ) ;
229
+ const C = new Array ( facets . length ) ;
230
230
const [ cx , cy ] = applyFrameAnchor ( this , dimensions ) ;
231
231
const xi = X ? ( i ) => X [ i ] : constant ( cx ) ;
232
232
const yi = Y ? ( i ) => Y [ i ] : constant ( cy ) ;
233
233
for ( let [ fi , facet ] of facets . entries ( ) ) {
234
234
if ( X ) facet = facet . filter ( ( i ) => defined ( X [ i ] ) ) ;
235
235
if ( Y ) facet = facet . filter ( ( i ) => defined ( Y [ i ] ) ) ;
236
+ const Cf = C [ fi ] = [ ] ;
236
237
for ( const [ , index ] of maybeGroup ( facet , Z ) ) {
237
238
const delaunay = Delaunay . from ( index , xi , yi ) ;
238
239
const voronoi = voronoiof ( delaunay , dimensions ) ;
239
240
for ( let i = 0 , n = index . length ; i < n ; ++ i ) {
240
- const c = voronoi . renderCell ( i ) ;
241
- if ( c ) ( C [ index [ i ] ] ||= [ ] ) [ fi ] = c ;
241
+ Cf [ index [ i ] ] = voronoi . renderCell ( i ) ;
242
242
}
243
243
}
244
244
}
245
- return { data, facets, channels : { cells : { value : C } } } ;
245
+ return { data, facets, channels : { cells : { value : C , filter : null } } } ;
246
246
} ) ,
247
247
voronoiDefaults
248
248
) ;
249
249
}
250
250
render ( index , scales , channels , dimensions , context ) {
251
251
const { x, y} = scales ;
252
- const { x : X , y : Y , cells : C } = channels ;
253
- const fi = index . fi ?? 0 ;
252
+ const { x : X , y : Y , cells : { [ index . fi ?? 0 ] : C } } = channels ;
254
253
return create ( "svg:g" , context )
255
254
. call ( applyIndirectStyles , this , dimensions , context )
256
255
. call ( applyTransform , this , { x : X && x , y : Y && y } )
257
256
. call ( ( g ) => {
258
257
g . selectAll ( )
259
- . data ( index )
258
+ . data ( index . filter ( ( i ) => C [ i ] != null ) )
260
259
. enter ( )
261
260
. append ( "path" )
262
261
. call ( applyDirectStyles , this )
263
- . attr ( "d" , ( i ) => C [ i ] [ fi ] )
262
+ . attr ( "d" , ( i ) => C [ i ] )
264
263
. call ( applyChannelStyles , this , channels ) ;
265
264
} )
266
265
. node ( ) ;
0 commit comments