Created
May 10, 2020 17:55
-
-
Save domoritz/1efe73556e1f1e88cc5a9847fee7e6b8 to your computer and use it in GitHub Desktop.
Window smoothing with filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v4.json", | |
"data": {"sequence": {"start": 0, "stop": 100, "as": "x"}}, | |
"transform": [{"calculate": "random() * sin(datum.x/10)", "as": "y"}], | |
"vconcat": [ | |
{ | |
"width": 600, | |
"mark": "line", | |
"encoding": { | |
"x": {"field": "x", "type": "quantitative"}, | |
"y": {"field": "y", "type": "quantitative"} | |
} | |
}, | |
{ | |
"width": 600, | |
"transform": [ | |
{"filter": "datum.x < end"}, | |
{ | |
"window": [{"field": "y", "op": "mean", "as": "mean"}], | |
"frame": [-10, 10] | |
} | |
], | |
"mark": "line", | |
"encoding": { | |
"x": { | |
"field": "x", | |
"type": "quantitative", | |
"scale": {"domain": [0, 100]} | |
}, | |
"y": {"field": "mean", "type": "quantitative"} | |
} | |
} | |
], | |
"config": { | |
"signals": [{"name": "end", "value": 50, "bind": {"type": "range"}}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment