Skip to content

Commit

Permalink
pad the data with duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed May 28, 2023
1 parent ad0bfc1 commit 15e303a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/transforms/exclusiveFacets.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ export function exclusiveFacets(data, facets) {
if (overlaps === 0) return {data, facets}; // facets are exclusive

// For each overlapping index (duplicate), assign a new unique index at the
// end of the existing array. For example, [[0, 1, 2], [2, 1, 3]] would become
// [[0, 1, 2], [4, 5, 3]]. Attach a plan to the facets array, to be able to
// read the values associated with the old index in unaffected channels.
// end of the existing array, duplicating the datum. For example, [[0, 1, 2],
// [2, 1, 3]] would become [[0, 1, 2], [4, 5, 3]].
data = slice(data);
facets = facets.map((facet) => slice(facet, Uint32Array));
let j = n;
O.fill(0);
for (const facet of facets) {
for (let k = 0, m = facet.length; k < m; ++k) {
const i = facet[k];
if (O[i]) facet[k] = j++;
if (O[i]) (facet[k] = j), (data[j] = data[i]), ++j;
O[i] = 1;
}
}
Expand Down

0 comments on commit 15e303a

Please sign in to comment.