{ "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": { "url": "https://vega.github.io/vega-lite/data/movies.json" }, "description": "A scatterplot showing each movie in the database and the difference from the average movie rating.", "encoding": { "x": { "field": "Release_Date", "type": "temporal" }, "y": { "axis": { "title": "Residual" }, "field": "RatingDelta", "type": "quantitative" } }, "mark": { "opacity": 0.3, "strokeWidth": 0.3, "type": "point" }, "transform": [ { "filter": "isValid(datum.IMDB_Rating)" }, { "filter": { "field": "Release_Date", "range": [ null, { "year": 2019 } ] } }, { "frame": [ null, null ], "window": [ { "as": "AverageRating", "field": "IMDB_Rating", "op": "mean" } ] }, { "as": "RatingDelta", "calculate": "datum.IMDB_Rating - datum.AverageRating" } ] }