Skip to content

Commit

Permalink
better error message for missing stack value (#1798)
Browse files Browse the repository at this point in the history
* better error message for missing channel

* linked pointer example

* shorten error message
  • Loading branch information
mbostock authored and Fil committed Aug 21, 2023
1 parent c5b0a1a commit e6dccb4
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/transforms/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function mergeOptions(options) {
const lengthy = {length: true};

function stack(x, y = one, kx, ky, {offset, order, reverse}, options) {
if (y === null) throw new Error(`stack requires ${ky}`);
const z = maybeZ(options);
const [X, setX] = maybeColumn(x);
const [Y1, setY1] = column(y);
Expand Down
70 changes: 70 additions & 0 deletions test/output/pointerLinkedRectInterval.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 @@ -208,6 +208,7 @@ export * from "./penguin-species-island-sex.js";
export * from "./penguin-species-island.js";
export * from "./penguin-species.js";
export * from "./penguin-voronoi-1d.js";
export * from "./pointer-linked.js";
export * from "./pointer.js";
export * from "./polylinear.js";
export * from "./population-by-latitude.js";
Expand Down
16 changes: 16 additions & 0 deletions test/plots/pointer-linked.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";

export async function pointerLinkedRectInterval() {
const a = d3.range(10).map((i) => ({series: "A", time: i, value: 15 + i - 0.3 * (i * i)}));
const b = d3.range(12).map((i) => ({series: "B", time: i, value: 12 * i - i * i}));
const round = {floor: (x) => Math.floor(x) - 0.5, offset: (x) => x + 1};
const series = [...a, ...b];
return Plot.plot({
marks: [
Plot.rect(series, Plot.pointerX({x: "time", interval: round, fillOpacity: 0.1})),
Plot.lineY(series, {stroke: "series", x: "time", y: "value", marker: true, curve: "natural"}),
Plot.arrow(series, Plot.pointerX(Plot.groupX({y1: "min", y2: "max"}, {x: "time", y: "value", inset: 10})))
]
});
}

0 comments on commit e6dccb4

Please sign in to comment.