{ "transform": [ { "groupby": [ "Origin", "Cylinders" ], "aggregate": [ { "op": "count", "as": "count_*" } ] }, { "groupby": [], "as": [ "stack_count_Origin1", "stack_count_Origin2" ], "offset": "normalize", "sort": [ { "field": "Origin", "order": "ascending" } ], "stack": "count_*" }, { "window": [ { "op": "min", "as": "x", "field": "stack_count_Origin1" }, { "op": "max", "as": "x2", "field": "stack_count_Origin2" }, { "op": "dense_rank", "as": "rank_Cylinders" }, { "op": "distinct", "as": "distinct_Cylinders", "field": "Cylinders" } ], "groupby": [ "Origin" ], "sort": [ { "field": "Cylinders", "order": "ascending" } ], "frame": [ null, null ] }, { "window": [ { "op": "dense_rank", "as": "rank_Origin" } ], "sort": [ { "field": "Origin", "order": "ascending" } ], "frame": [ null, null ] }, { "groupby": [ "Origin" ], "as": [ "y", "y2" ], "offset": "normalize", "sort": [ { "field": "Cylinders", "order": "ascending" } ], "stack": "count_*" }, { "as": "ny", "calculate": "datum.y + (datum.rank_Cylinders - 1) * datum.distinct_Cylinders * 0.01 / 3" }, { "as": "ny2", "calculate": "datum.y2 + (datum.rank_Cylinders - 1) * datum.distinct_Cylinders * 0.01 / 3" }, { "as": "nx", "calculate": "datum.x + (datum.rank_Origin - 1) * 0.01" }, { "as": "nx2", "calculate": "datum.x2 + (datum.rank_Origin - 1) * 0.01" }, { "as": "xc", "calculate": "(datum.nx+datum.nx2)/2" }, { "as": "yc", "calculate": "(datum.ny+datum.ny2)/2" } ], "config": { "concat": { "spacing": 10 }, "view": { "stroke": null }, "axis": { "domain": false, "labels": false, "grid": false, "ticks": false } }, "data": { "url": "https://vega.github.io/vega-lite/data/cars.json" }, "resolve": { "scale": { "x": "shared" } }, "vconcat": [ { "mark": { "align": "center", "type": "text", "baseline": "middle" }, "encoding": { "color": { "field": "Origin", "type": "nominal", "legend": null }, "text": { "field": "Origin", "type": "nominal" }, "x": { "field": "xc", "aggregate": "min", "title": "Origin", "type": "quantitative", "axis": { "orient": "top" } } } }, { "layer": [ { "mark": "rect", "encoding": { "x2": { "field": "nx2" }, "color": { "field": "Origin", "type": "nominal", "legend": null }, "opacity": { "field": "Cylinders", "type": "quantitative", "legend": null }, "tooltip": [ { "field": "Origin", "type": "nominal" }, { "field": "Cylinders", "type": "quantitative" } ], "x": { "field": "nx", "type": "quantitative", "axis": null }, "y2": { "field": "ny2" }, "y": { "field": "ny", "type": "quantitative", "axis": null } } }, { "mark": { "type": "text", "baseline": "middle" }, "encoding": { "text": { "field": "Cylinders", "type": "nominal" }, "x": { "field": "xc", "type": "quantitative", "axis": null }, "y": { "field": "yc", "type": "quantitative", "axis": { "title": "Cylinders" } } } } ] } ], "$schema": "https://vega.github.io/schema/vega-lite/v4.json" }