1
- import { slice } from "../options.js" ;
1
+ import { reindex , slice } from "../options.js" ;
2
2
3
3
export function exclusiveFacets ( data , facets ) {
4
4
if ( facets . length === 1 ) return { data, facets} ; // only one facet; trivially exclusive
@@ -20,18 +20,18 @@ export function exclusiveFacets(data, facets) {
20
20
21
21
// For each overlapping index (duplicate), assign a new unique index at the
22
22
// end of the existing array, duplicating the datum. For example, [[0, 1, 2],
23
- // [2, 1, 3]] would become [[0, 1, 2], [4, 5, 3]].
23
+ // [2, 1, 3]] would become [[0, 1, 2], [4, 5, 3]]. Also attach a reindex to
24
+ // the data to preserve the association of channel values specified as arrays.
24
25
data = slice ( data ) ;
25
- // Attach a reindex map to the data, to interpret channels specified as arrays.
26
- data . reindex = new Uint32Array ( n + overlaps ) ;
26
+ const R = ( data [ reindex ] = new Uint32Array ( n + overlaps ) ) ;
27
27
facets = facets . map ( ( facet ) => slice ( facet , Uint32Array ) ) ;
28
28
let j = n ;
29
29
O . fill ( 0 ) ;
30
30
for ( const facet of facets ) {
31
31
for ( let k = 0 , m = facet . length ; k < m ; ++ k ) {
32
32
const i = facet [ k ] ;
33
- if ( O [ i ] ) ( facet [ k ] = j ) , ( data [ j ] = data [ i ] ) , ( data . reindex [ j ] = i ) , ++ j ;
34
- else data . reindex [ i ] = i ;
33
+ if ( O [ i ] ) ( facet [ k ] = j ) , ( data [ j ] = data [ i ] ) , ( R [ j ] = i ) , ++ j ;
34
+ else R [ i ] = i ;
35
35
O [ i ] = 1 ;
36
36
}
37
37
}
0 commit comments