Skip to content

Commit 279a84d

Browse files
authored
fix missing facet data error (#1521)
1 parent 78db2bb commit 279a84d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/plot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ function maybeTopFacet(facet, options) {
398398
if (facet == null) return;
399399
const {x, y} = facet;
400400
if (x == null && y == null) return;
401-
const data = arrayify(facet.data ?? x ?? y);
402-
if (data === undefined) throw new Error(`missing facet data`);
401+
const data = arrayify(facet.data);
402+
if (data == null) throw new Error("missing facet data");
403403
const channels = {};
404404
if (x != null) channels.fx = createChannel(data, {value: x, scale: "fx"});
405405
if (y != null) channels.fy = createChannel(data, {value: y, scale: "fy"});

test/facet-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ it("mark data not parallel to facet data does not trigger a warning", async () =
3131
Plot.dot(data.slice(0, 1), {x: "x", y: "y", facet: undefined}).plot({facet: {data, x: "series"}})
3232
);
3333
});
34+
35+
it("detects missing facet data", async () => {
36+
assert.throws(() => Plot.barY([], {x: "x", y: "y"}).plot({facet: {x: "fx"}}), /missing facet data/);
37+
assert.throws(() => Plot.barY([], {x: "x", y: "y"}).plot({facet: {data: null, x: "fx"}}), /missing facet data/);
38+
});

0 commit comments

Comments
 (0)