-
I'm doing a graph like this https://observablehq.com/d/2d5429036206e1ae the data is a monthly series data, to show a website's active users, as the column 0: Object {month: 2021-12-01, num_users: 10957, num_users_m3a: 4684}
1: Object {month: 2021-11-01, num_users: 10529, num_users_m3a: 3974}
2: Object {month: 2021-10-01, num_users: 10357, num_users_m3a: 5638}
3: Object {month: 2021-09-01, num_users: 10226, num_users_m3a: 5554}
4: Object {month: 2021-08-01, num_users: 9936, num_users_m3a: 5247} here want to add a link between each 3 months pair, something like this but this does not work, Plot.link(stats, {
x1: d => d3.utcMonth(d.month, -3), x2: "month",
y1: "num_users", // here actually want to select the prior 3months' num_users data
y2: "num_users",
stroke: "red",
}) I tried
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
you could try and use Plot.link(stats, Plot.map({
y1: Plot.window({ k: 4, anchor: "end", reduce: d => d[0] }),
x1: Plot.window({ k: 4, anchor: "end", reduce: d => d[0] }),
}, {
x1: "month",
x2: "month",
y1: "num_users_m3a",
y2: "num_users",
stroke: "red",
})) |
Beta Was this translation helpful? Give feedback.
you could try and use