{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "data": [ {"name": "source_0", "url": "data/cars.json", "format": {"type": "json"}}, { "name": "column_domain", "source": "source_0", "transform": [{"type": "aggregate", "groupby": ["Origin"]}] }, { "name": "data_2", "source": "source_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Acceleration\"]) && isFinite(+datum[\"Acceleration\"])" } ] } ], "signals": [ {"name": "child_child_width", "value": 200}, {"name": "child_child_height", "value": 200} ], "layout": { "padding": 20, "headerBand": {"column": 0.5}, "offset": {"columnTitle": 10}, "columns": {"signal": "length(data('column_domain'))"}, "bounds": "full", "align": "all" }, "marks": [ { "name": "column-title", "type": "group", "role": "column-title", "title": {"text": "Origin", "style": "guide-title", "offset": 10} }, { "name": "column_header", "type": "group", "role": "column-header", "from": {"data": "column_domain"}, "sort": {"field": "datum[\"Origin\"]", "order": "ascending"}, "title": { "text": { "signal": "isValid(parent[\"Origin\"]) ? parent[\"Origin\"] : \"\"+parent[\"Origin\"]" }, "style": "guide-label", "frame": "group", "offset": 10 } }, { "name": "cell", "type": "group", "from": { "facet": {"name": "facet", "data": "source_0", "groupby": ["Origin"]} }, "sort": {"field": ["datum[\"Origin\"]"], "order": ["ascending"]}, "data": [ { "name": "child_row_domain", "source": "facet", "transform": [{"type": "aggregate", "groupby": ["Cylinders"]}] } ], "layout": { "padding": 20, "offset": {"rowTitle": 10}, "columns": 1, "bounds": "full", "align": "all" }, "marks": [ { "name": "row-title", "type": "group", "role": "row-title", "title": { "text": "Cylinders", "orient": "left", "style": "guide-title", "offset": 10 } }, { "name": "child_row_header", "type": "group", "role": "row-header", "from": {"data": "child_row_domain"}, "sort": {"field": "datum[\"Cylinders\"]", "order": "ascending"}, "title": { "text": { "signal": "isValid(parent[\"Cylinders\"]) ? parent[\"Cylinders\"] : \"\"+parent[\"Cylinders\"]" }, "orient": "left", "style": "guide-label", "frame": "group", "offset": 10 }, "encode": {"update": {"height": {"signal": "child_child_height"}}}, "axes": [ { "scale": "y", "orient": "left", "grid": false, "title": "Acceleration", "labelOverlap": true, "tickCount": {"signal": "ceil(child_child_height/40)"}, "zindex": 0 } ] }, { "name": "child_column_footer", "type": "group", "role": "column-footer", "encode": {"update": {"width": {"signal": "child_child_width"}}}, "axes": [ { "scale": "x", "orient": "bottom", "grid": false, "title": "Horsepower", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(child_child_width/40)"}, "zindex": 0 } ] }, { "name": "child_cell", "type": "group", "style": "cell", "from": { "facet": { "name": "child_facet", "data": "facet", "groupby": ["Cylinders"] } }, "sort": {"field": ["datum[\"Cylinders\"]"], "order": ["ascending"]}, "data": [ { "source": "child_facet", "name": "data_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Acceleration\"]) && isFinite(+datum[\"Acceleration\"])" } ] } ], "encode": { "update": { "width": {"signal": "child_child_width"}, "height": {"signal": "child_child_height"} } }, "marks": [ { "name": "child_child_marks", "type": "symbol", "style": ["point"], "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "transparent"}, "stroke": {"value": "#4c78a8"}, "ariaRoleDescription": {"value": "point"}, "description": { "signal": "\"Horsepower: \" + (format(datum[\"Horsepower\"], \"\")) + \"; Acceleration: \" + (format(datum[\"Acceleration\"], \"\"))" }, "x": {"scale": "x", "field": "Horsepower"}, "y": {"scale": "y", "field": "Acceleration"} } } } ], "axes": [ { "scale": "x", "orient": "bottom", "gridScale": "y", "grid": true, "tickCount": {"signal": "ceil(child_child_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(child_child_height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 } ] } ] } ], "scales": [ { "name": "x", "type": "linear", "domain": {"data": "data_2", "field": "Horsepower"}, "range": [0, {"signal": "child_child_width"}], "nice": true, "zero": true }, { "name": "y", "type": "linear", "domain": {"data": "data_2", "field": "Acceleration"}, "range": [{"signal": "child_child_height"}, 0], "nice": true, "zero": true } ] }