Skip to content

warn about ignored indices #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/defined.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ export function nonempty(x) {
}

export function filter(index, ...channels) {
const ignored = [];
for (const c of channels) {
if (c) index = index.filter(i => defined(c[i]));
if (c) {
const test = typeof c === "function" ? c : i => defined(c[i]);
index = index.filter(i => test(i) || (ignored.push(i), false));
}
}
if (ignored.length > 0) {
console.warn(`ignored indices:`, ignored);
}
return index;
}
Expand Down
3 changes: 1 addition & 2 deletions src/marks/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export class Dot extends Mark {
) {
const {x: X, y: Y, r: R} = channels;
const {dx, dy} = this;
let index = filter(I, X, Y);
if (R) index = index.filter(i => positive(R[i]));
const index = filter(I, X, Y, R && (i => positive(R[i])));
return create("svg:g")
.call(applyIndirectStyles, this)
.call(applyTransform, x, y, offset + dx, offset + dy)
Expand Down
2 changes: 1 addition & 1 deletion src/marks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Text extends Mark {
const {x: X, y: Y, rotate: R, text: T, fontSize: FS} = channels;
const {width, height, marginTop, marginRight, marginBottom, marginLeft} = dimensions;
const {rotate} = this;
const index = filter(I, X, Y, R).filter(i => nonempty(T[i]));
const index = filter(I, X, Y, R, i => nonempty(T[i]));
const cx = (marginLeft + width - marginRight) / 2;
const cy = (marginTop + height - marginBottom) / 2;
return create("svg:g")
Expand Down