{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ {"name": "pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_store"}, { "name": "df", "url": "https://raw.githubusercontent.com/vega/vega-datasets/next/data/movies.json", "format": {"type": "json", "parse": {"Release Date": "date"}} }, { "name": "data_0", "source": "df", "transform": [ { "field": "Release Date", "type": "timeunit", "units": ["year"], "as": ["year_Release Date", "year_Release Date_end"] } ] }, { "name": "data_1", "source": "data_0", "transform": [ { "type": "filter", "expr": "(isDate(datum[\"year_Release Date\"]) || (isValid(datum[\"year_Release Date\"]) && isFinite(+datum[\"year_Release Date\"]))) && isValid(datum[\"US Gross\"]) && isFinite(+datum[\"US Gross\"])" } ] }, { "name": "data_2", "source": "df", "transform": [ { "type": "pivot", "field": "MPAA Rating", "value": "US Gross", "groupby": ["Release Date"] }, { "type": "formula", "expr": "toDate(datum[\"Release Date\"])", "as": "Release Date" }, { "field": "Release Date", "type": "timeunit", "units": ["year"], "as": ["year_Release Date", "year_Release Date_end"] }, { "type": "filter", "expr": "(isDate(datum[\"year_Release Date\"]) || (isValid(datum[\"year_Release Date\"]) && isFinite(+datum[\"year_Release Date\"])))" } ] }, { "name": "data_3", "source": "df", "transform": [ { "type": "aggregate", "groupby": ["MPAA Rating"], "ops": [], "fields": [], "as": [] }, { "type": "window", "params": [null], "as": ["rank"], "ops": ["rank"], "fields": [null], "sort": {"field": [], "order": []} }, {"type": "filter", "expr": "datum.rank <= 21"} ] } ], "signals": [ { "name": "unit", "value": {}, "on": [ {"events": "mousemove", "update": "isTuple(group()) ? group() : unit"} ] }, { "name": "pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24", "update": "vlSelectionResolve(\"pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_store\", \"union\", true, true)" }, { "name": "pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_tuple", "on": [ { "events": [ { "source": "scope", "type": "mouseover", "markname": "layer_0_layer_1_layer_0_voronoi" } ], "update": "datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0 ? {unit: \"layer_0_layer_1_layer_0\", fields: pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_tuple_fields, values: [(item().isVoronoi ? datum.datum : datum)[\"year_Release Date\"]]} : null", "force": true }, {"events": [{"source": "view", "type": "mouseout"}], "update": "null"} ] }, { "name": "pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_tuple_fields", "value": [{"type": "E", "field": "year_Release Date"}] }, { "name": "pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_toggle", "value": false, "on": [ { "events": [ { "source": "scope", "type": "mouseover", "markname": "layer_0_layer_1_layer_0_voronoi" } ], "update": "event.shiftKey" }, {"events": [{"source": "view", "type": "mouseout"}], "update": "false"} ] }, { "name": "pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_modify", "on": [ { "events": { "signal": "pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_tuple" }, "update": "modify(\"pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_store\", pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_toggle ? null : pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_tuple, pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_toggle ? null : true, pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_toggle ? pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_tuple : null)" } ] } ], "marks": [ { "name": "layer_0_layer_0_layer_0_pathgroup", "type": "group", "from": { "facet": { "name": "faceted_path_layer_0_layer_0_layer_0_main", "data": "data_0", "groupby": ["MPAA Rating"] } }, "encode": { "update": { "width": {"field": {"group": "width"}}, "height": {"field": {"group": "height"}} } }, "marks": [ { "name": "layer_0_layer_0_layer_0_marks", "type": "line", "clip": true, "style": ["line"], "sort": {"field": "datum[\"year_Release Date\"]"}, "interactive": false, "from": {"data": "faceted_path_layer_0_layer_0_layer_0_main"}, "encode": { "update": { "stroke": { "scale": "layer_0_layer_0_color", "field": "MPAA Rating" }, "opacity": {"value": 1}, "description": { "signal": "\"Release Date (year): \" + (timeFormat(datum[\"year_Release Date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; US Gross: \" + (format(datum[\"US Gross\"], \"\")) + \"; MPAA Rating: \" + (isValid(datum[\"MPAA Rating\"]) ? datum[\"MPAA Rating\"] : \"\"+datum[\"MPAA Rating\"])" }, "x": {"scale": "x", "field": "year_Release Date"}, "y": {"scale": "y", "field": "US Gross"}, "defined": { "signal": "isValid(datum[\"year_Release Date\"]) && isFinite(+datum[\"year_Release Date\"]) && isValid(datum[\"US Gross\"]) && isFinite(+datum[\"US Gross\"])" } } } } ] }, { "name": "__drilldown_brush_marks", "type": "symbol", "style": ["point"], "interactive": false, "from": {"data": "data_1"}, "encode": { "update": { "opacity": {"value": 0}, "fill": {"value": "transparent"}, "stroke": {"scale": "layer_0_layer_0_color", "field": "MPAA Rating"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Release Date (year): \" + (timeFormat(datum[\"year_Release Date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; US Gross: \" + (format(datum[\"US Gross\"], \"\")) + \"; MPAA Rating: \" + (isValid(datum[\"MPAA Rating\"]) ? datum[\"MPAA Rating\"] : \"\"+datum[\"MPAA Rating\"])" }, "x": {"scale": "x", "field": "year_Release Date"}, "y": {"scale": "y", "field": "US Gross"} } } }, { "name": "layer_0_layer_0_layer_2_marks", "type": "symbol", "style": ["point"], "interactive": false, "from": {"data": "data_1"}, "encode": { "update": { "opacity": [ { "test": "length(data(\"pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_store\")) && vlSelectionTest(\"pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_store\", datum)", "value": 1 }, {"value": 0} ], "fill": {"value": "transparent"}, "stroke": {"scale": "layer_0_layer_0_color", "field": "MPAA Rating"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Release Date (year): \" + (timeFormat(datum[\"year_Release Date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))) + \"; US Gross: \" + (format(datum[\"US Gross\"], \"\")) + \"; MPAA Rating: \" + (isValid(datum[\"MPAA Rating\"]) ? datum[\"MPAA Rating\"] : \"\"+datum[\"MPAA Rating\"])" }, "x": {"scale": "x", "field": "year_Release Date"}, "y": {"scale": "y", "field": "US Gross"}, "size": {"value": 80} } } }, { "name": "layer_0_layer_1_layer_0_marks", "type": "rule", "style": ["rule"], "interactive": true, "from": {"data": "data_2"}, "encode": { "update": { "stroke": {"value": "CHART_DEFAULT_RULE_COLOR_MARKER"}, "opacity": [ { "test": "length(data(\"pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_store\")) && vlSelectionTest(\"pivot_hover_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_store\", datum)", "value": 0.3 }, {"value": 0} ], "tooltip": { "signal": "{\"Release Date (year)\": timeFormat(datum[\"year_Release Date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))}" }, "description": { "signal": "\"Release Date (year): \" + (timeFormat(datum[\"year_Release Date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})))" }, "x": {"scale": "x", "field": "year_Release Date"}, "y": {"value": 0}, "y2": {"field": {"group": "height"}} } } }, { "name": "layer_0_layer_1_layer_0_voronoi", "type": "path", "interactive": true, "from": {"data": "layer_0_layer_1_layer_0_marks"}, "encode": { "update": { "fill": {"value": "transparent"}, "strokeWidth": {"value": 0.35}, "stroke": {"value": "transparent"}, "isVoronoi": {"value": true}, "tooltip": { "signal": "{\"Release Date (year)\": timeFormat(datum.datum[\"year_Release Date\"], timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"}))}" } } }, "transform": [ { "type": "voronoi", "x": {"expr": "datum.datum.x || 0"}, "y": {"expr": "datum.datum.y || 0"}, "size": [{"signal": "width"}, {"signal": "height"}] } ] }, { "name": "aggregate_color_spec_878b1bec_a2a8_42c5_b9ab_bfcf98f79b24_marks", "type": "rule", "style": ["rule"], "interactive": false, "from": {"data": "data_3"}, "encode": {"update": {}} } ], "scales": [ { "name": "x", "type": "time", "domain": { "fields": [ {"data": "data_0", "field": "year_Release Date"}, {"data": "data_1", "field": "year_Release Date"}, {"data": "data_2", "field": "year_Release Date"} ] }, "range": [0, {"signal": "width"}] }, { "name": "y", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "US Gross"}, {"data": "data_1", "field": "US Gross"} ] }, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "layer_0_layer_0_color", "type": "ordinal", "domain": { "fields": [ {"data": "data_0", "field": "MPAA Rating"}, {"data": "data_1", "field": "MPAA Rating"} ], "sort": true }, "range": "category" } ], "axes": [ { "scale": "x", "orient": "bottom", "grid": true, "gridScale": "y", "tickCount": {"signal": "ceil(width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": true, "gridScale": "x", "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 (year)", "labels": true, "ticks": true, "format": { "signal": "timeUnitSpecifier([\"year\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" }, "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "US Gross", "labels": true, "ticks": true, "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "legends": [ { "symbolType": "stroke", "stroke": "layer_0_layer_0_color", "title": "MPAA Rating", "encode": {"symbols": {"update": {"opacity": {"value": 1}}}} } ], "config": { "range": {"ramp": {"scheme": "yellowgreenblue"}}, "axis": {"domain": false}, "legend": {"orient": "right"} } }