Display Most Recent Rolling Average #2161
-
For the past couple of days I've been trying to figure out how to display the most recent rolling average value. Using this fork, I've added the text mark in an effort to accomplish this but it appears to only display the last value from the data though displayed at that average point. Here's essentially the snippt: Plot.textY(sftemp,
Plot.selectLast(
Plot.windowY({ k: 28 }, { x: "date", y: "high", text: "high" })
)
) In this screenshot, I goal is for the red number to be the value of the blue line (shown in bottom tip), but it's displaying the actual data point instead (shown in the top tip). Am I missing something or is this accomplished a different way?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
which you can apply to multiple channels like so:
See https://observablehq.com/plot/transforms/window (You can also define |
Beta Was this translation helpful? Give feedback.
Plot.windowY({k: 28, anchor, strict, ...options})
is a shorthand notation for:Plot.map({y: Plot.window({ k: 28, anchor, strict })}, options)
which you can apply to multiple channels like so:
See https://observablehq.com/plot/transforms/window
(You can also define
window = Plot.window({ k: 28, anchor, strict })
and writePlot.map({text: window, y: window}, options)
)