Observable Plot: Using moving average values in a tooltip instead of raw values

Hi,
I’m using slightly modified code from this github issue A grouped tip for multi-series plots · Issue #2003 · observablehq/plot · GitHub. It has worked wonderfully but I’m trying to modify it to accurately display values on a plot I’m doing where I’m using Plot.windowY to do a moving average, e.g. correct values on a plot like this Plot: grouped tips / Jeremy Rifkin | Observable.

I’ve tried a few things, including a few Plot.windowX/Y ideas and a Plot.map idea, but I ran into problems due to the text transform using the raw data point.

                      Plot.text(data, {
                        y: "industry",
                        text: (data) => data.unemployed.toExponential(3),
                        frameAnchor: "right",
                        dx: -2
                      }),

I have tried a few other ideas with ditching most of the render function passed to binX but I can’t find a formulation which allows accessing the moving average value as opposed to the raw value.

Is there any way to get the correct value within this tooltip?

We’re now using GitHub discussions to talk about Plot. I think this is similar to this discussion: Display Most Recent Rolling Average · observablehq/plot · Discussion #2161 · GitHub

Let us know if it helps.

Oh amazing, that looks like exactly what I am trying to do. Thank you so much!