{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "A dot plot showing each movie in the database, and the difference from the average movie rating. The display is sorted by year to visualize everything in sequential order. The graph is for all Movies before 2019.", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/movies.json", "format": {"type": "json", "parse": {"Release Date": "date"}}, "transform": [ {"type": "filter", "expr": "datum['IMDB Rating'] != null"}, { "type": "filter", "expr": "time(datetime(year(datum[\"Release Date\"]), 0, 1, 0, 0, 0, 0)) <= time(datetime(2019, 0, 1, 0, 0, 0, 0))" }, { "type": "joinaggregate", "as": ["AverageRating"], "ops": ["mean"], "fields": ["IMDB Rating"] }, { "type": "formula", "expr": "datum['IMDB Rating'] - datum.AverageRating", "as": "RatingDelta" }, { "type": "filter", "expr": "(isDate(datum[\"Release Date\"]) || (isValid(datum[\"Release Date\"]) && isFinite(+datum[\"Release Date\"]))) && isValid(datum[\"RatingDelta\"]) && isFinite(+datum[\"RatingDelta\"])" } ] } ], "marks": [ { "name": "marks", "type": "symbol", "style": ["point"], "from": {"data": "source_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "transparent"}, "stroke": {"scale": "color", "field": "RatingDelta"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Release Date: \" + (timeFormat(datum[\"Release Date\"], '%b %d, %Y')) + \"; Rating Delta: \" + (format(datum[\"RatingDelta\"], \"\"))" }, "x": {"scale": "x", "field": "Release Date"}, "y": {"scale": "y", "field": "RatingDelta"} } } } ], "scales": [ { "name": "x", "type": "time", "domain": {"data": "source_0", "field": "Release Date"}, "range": [0, {"signal": "width"}] }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "RatingDelta"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "color", "type": "linear", "domain": {"data": "source_0", "field": "RatingDelta"}, "range": "diverging", "domainMid": 0, "interpolate": "hcl", "zero": false } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "tickCount": {"signal": "ceil(width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "y", "orient": "left", "gridScale": "x", "grid": true, "tickCount": {"signal": "ceil(height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "x", "orient": "bottom", "grid": false, "title": "Release Date", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Rating Delta", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "legends": [ { "title": "Rating Delta", "stroke": "color", "gradientLength": {"signal": "clamp(height, 64, 200)"}, "encode": {"gradient": {"update": {"opacity": {"value": 0.7}}}} } ] }