|
1 | 1 | import {count, group, rank} from "d3";
|
2 | 2 | import {maybeZ, take, valueof, maybeInput, column} from "../options.js";
|
3 | 3 | import {basic} from "./basic.js";
|
| 4 | +import {facetReindex, getter, expander} from "../facet.js"; |
4 | 5 |
|
5 | 6 | /**
|
6 | 7 | * ```js
|
@@ -58,11 +59,13 @@ export function map(outputs = {}, options = {}) {
|
58 | 59 | });
|
59 | 60 | return {
|
60 | 61 | ...basic(options, (data, facets) => {
|
| 62 | + // make facets exclusive |
| 63 | + facets = facetReindex(facets, data.length); |
61 | 64 | const Z = valueof(data, z);
|
62 |
| - const X = channels.map(({input}) => valueof(data, input)); |
63 |
| - const MX = channels.map(({setOutput}) => setOutput(new Array(data.length))); |
| 65 | + const X = channels.map(({input}) => expander(facets, valueof(data, input))); |
| 66 | + const MX = channels.map(({setOutput}) => setOutput(new Array((facets.plan || data).length))); |
64 | 67 | for (const facet of facets) {
|
65 |
| - for (const I of Z ? group(facet, (i) => Z[i]).values() : [facet]) { |
| 68 | + for (const I of Z ? group(facet, getter(facets, Z)).values() : [facet]) { |
66 | 69 | channels.forEach(({map}, i) => map.map(I, X[i], MX[i]));
|
67 | 70 | }
|
68 | 71 | }
|
|
0 commit comments