Skip to content

Commit a68685d

Browse files
committed
warn about ignored indices
for #493 #536
1 parent 2da25ec commit a68685d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/defined.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ export function nonempty(x) {
1717
}
1818

1919
export function filter(index, ...channels) {
20+
const ignored = [];
2021
for (const c of channels) {
21-
if (c) index = index.filter(i => defined(c[i]));
22+
if (c) {
23+
const test = typeof c === "function" ? c : i => defined(c[i]);
24+
index = index.filter(i => test(i) || (ignored.push(i), false));
25+
}
26+
}
27+
if (ignored.length > 0) {
28+
console.warn(`ignored indices:`, ignored);
2229
}
2330
return index;
2431
}

src/marks/dot.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ export class Dot extends Mark {
3333
) {
3434
const {x: X, y: Y, r: R} = channels;
3535
const {dx, dy} = this;
36-
let index = filter(I, X, Y);
37-
if (R) index = index.filter(i => positive(R[i]));
36+
const index = filter(I, X, Y, R && (i => positive(R[i])));
3837
return create("svg:g")
3938
.call(applyIndirectStyles, this)
4039
.call(applyTransform, x, y, offset + dx, offset + dy)

src/marks/text.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Text extends Mark {
5151
const {x: X, y: Y, rotate: R, text: T, fontSize: FS} = channels;
5252
const {width, height, marginTop, marginRight, marginBottom, marginLeft} = dimensions;
5353
const {rotate} = this;
54-
const index = filter(I, X, Y, R).filter(i => nonempty(T[i]));
54+
const index = filter(I, X, Y, R, i => nonempty(T[i]));
5555
const cx = (marginLeft + width - marginRight) / 2;
5656
const cy = (marginTop + height - marginBottom) / 2;
5757
return create("svg:g")

0 commit comments

Comments
 (0)