Skip to content

Commit f6eeea4

Browse files
committed
test
1 parent 14d6e43 commit f6eeea4

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

test/plots/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,5 @@ export * from "./yearly-requests-dot.js";
356356
export * from "./yearly-requests-line.js";
357357
export * from "./yearly-requests.js";
358358
export * from "./young-adults.js";
359+
export * from "./window.js";
359360
export * from "./zero.js";

test/plots/window.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import * as Plot from "@observablehq/plot";
2+
import * as d3 from "d3";
3+
4+
export async function windowZ() {
5+
const random = d3.randomLcg(42);
6+
const data = d3.sort(
7+
["a", "b", "c"].flatMap((type, i) =>
8+
d3.utcDay.range(new Date("2024-01-01"), new Date("2025-01-01"), [1, 7, 30][i]).map((date) => ({
9+
type,
10+
date,
11+
value: ((random() * 1000) | 0) + i * 1500
12+
}))
13+
),
14+
(d) => d.date
15+
);
16+
17+
return Plot.plot({
18+
y: {grid: true},
19+
marks: [
20+
Plot.dot(data, {
21+
x: "date",
22+
y: "value",
23+
fill: "type",
24+
r: 1.5
25+
}),
26+
Plot.lineY(
27+
data,
28+
Plot.windowY({
29+
x: "date",
30+
y: "value",
31+
anchor: "end",
32+
stroke: {value: "type"},
33+
k: 10,
34+
reduce: "mean",
35+
tip: true
36+
})
37+
)
38+
]
39+
});
40+
}

0 commit comments

Comments
 (0)