Skip to content

Commit

Permalink
fix crash during reindex (#2028)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock authored Mar 21, 2024
1 parent 4422636 commit 70ee172
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function valueof(data, value, type) {
}

function maybeTake(values, index) {
return index ? take(values, index) : values;
return values != null && index ? take(values, index) : values;
}

function maybeTypedMap(data, f, type) {
Expand Down
148 changes: 148 additions & 0 deletions test/output/mixedFacets.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/plots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export * from "./metro-unemployment-ridgeline.js";
export * from "./metro-unemployment-slope.js";
export * from "./metro-unemployment-stroke.js";
export * from "./metro-unemployment.js";
export * from "./mixed-facets.js";
export * from "./moby-dick-faceted.js";
export * from "./moby-dick-letter-frequency.js";
export * from "./moby-dick-letter-pairs.js";
Expand Down
20 changes: 20 additions & 0 deletions test/plots/mixed-facets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as Plot from "@observablehq/plot";

export async function mixedFacets() {
const data = [
{date: new Date("2024-01-01"), name: "a", value: 1},
{date: new Date("2024-01-01"), name: "b", value: 2},
{date: new Date("2024-01-01"), name: "a", value: 2},
{date: new Date("2024-02-01"), name: "b", value: 3},
{date: new Date("2024-02-01"), name: "a", value: 5},
{date: new Date("2024-02-01"), name: "b", value: 2},
{date: new Date("2024-02-01"), name: "a", value: 3}
];
return Plot.plot({
marks: [
Plot.barY(data, {x: "name", y: "value", fill: "name", fx: "date", fy: "name"}),
Plot.barY(data, {x: "name", y: "value", fx: "date", stroke: "currentColor"}),
Plot.ruleY([0])
]
});
}

0 comments on commit 70ee172

Please sign in to comment.