0
votes

With vega-lite, it is clear that you can aggregate data using standard methods like the mean, sum, etc. But what about a moving average?

Let's say I have some simple time series data, so the x-value is a date and the y-value is a value of some sort. Now let's say I want to render a line chart with that data, and then layer on top of it a moving average plot. Is there a standard way to do this using vega-lite?

I've tried to look for some sort of solution in the docs, but haven't been able to find any reference. It seems as though this is a common use-case and so I'm wondering if it exists?

If it doesn't, I guess I would just generate the moving average values myself.

1

1 Answers

1
votes

Vega-Lite includes a window transform that is designed for precisely this. You might be able to adapt the Cumulative Moving Average example from the documentation to the dataset you have in mind.