{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "The production budget of the movie that has the highest US Gross in each major genre.", "background": "white", "padding": 5, "width": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/movies.json", "format": {"type": "json"}, "transform": [ { "type": "aggregate", "groupby": ["Major Genre"], "ops": ["argmax"], "fields": ["US Gross"], "as": ["argmax_US_Gross"] }, { "type": "formula", "expr": "datum[\"argmax_US_Gross\"] && datum[\"argmax_US_Gross\"][\"Production Budget\"]", "as": "argmax_US_Gross.Production Budget" }, { "type": "stack", "groupby": ["Major Genre"], "field": "argmax_US_Gross\\.Production Budget", "sort": {"field": [], "order": []}, "as": [ "argmax_US_Gross.Production Budget._start", "argmax_US_Gross.Production Budget._end" ], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"argmax_US_Gross.Production Budget\"]) && isFinite(+datum[\"argmax_US_Gross.Production Budget\"])" } ] } ], "signals": [ {"name": "y_step", "value": 20}, { "name": "height", "update": "bandspace(domain('y').length, 0.1, 0.05) * y_step" } ], "marks": [ { "name": "marks", "type": "rect", "style": ["bar"], "from": {"data": "source_0"}, "encode": { "update": { "fill": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"argmax_US_Gross['Production Budget']: \" + (format(datum[\"argmax_US_Gross.Production Budget\"], \"\")) + \"; Major Genre: \" + (isValid(datum[\"Major Genre\"]) ? datum[\"Major Genre\"] : \"\"+datum[\"Major Genre\"])" }, "x": { "scale": "x", "field": "argmax_US_Gross\\.Production Budget\\._end" }, "x2": { "scale": "x", "field": "argmax_US_Gross\\.Production Budget\\._start" }, "y": {"scale": "y", "field": "Major Genre"}, "height": {"scale": "y", "band": 1} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "data": "source_0", "fields": [ "argmax_US_Gross\\.Production Budget\\._start", "argmax_US_Gross\\.Production Budget\\._end" ] }, "range": [0, {"signal": "width"}], "nice": true, "zero": true }, { "name": "y", "type": "band", "domain": {"data": "source_0", "field": "Major Genre", "sort": true}, "range": {"step": {"signal": "y_step"}}, "paddingInner": 0.1, "paddingOuter": 0.05 } ], "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": "x", "orient": "bottom", "grid": false, "title": "argmax_US_Gross['Production Budget']", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Major Genre", "zindex": 0 } ] }