{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "data": [ { "name": "source_0", "values": [ { "title": "Revenue", "subtitle": "US$, in thousands", "ranges": [150, 225, 300], "measures": [220, 270], "markers": [250] }, { "title": "Profit", "subtitle": "%", "ranges": [20, 25, 30], "measures": [21, 23], "markers": [26] }, { "title": "Order Size", "subtitle": "US$, average", "ranges": [350, 500, 600], "measures": [100, 320], "markers": [550] }, { "title": "New Customers", "subtitle": "count", "ranges": [1400, 2000, 2500], "measures": [1000, 1650], "markers": [2100] }, { "title": "Satisfaction", "subtitle": "out of 5", "ranges": [3.5, 4.25, 5], "measures": [3.2, 4.7], "markers": [4.4] } ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "formula", "expr": "datum[\"ranges\"] && datum[\"ranges\"][\"2\"]", "as": "ranges.2" }, { "type": "formula", "expr": "datum[\"ranges\"] && datum[\"ranges\"][\"1\"]", "as": "ranges.1" }, { "type": "formula", "expr": "datum[\"ranges\"] && datum[\"ranges\"][\"0\"]", "as": "ranges.0" }, { "type": "formula", "expr": "datum[\"measures\"] && datum[\"measures\"][\"1\"]", "as": "measures.1" }, { "type": "formula", "expr": "datum[\"measures\"] && datum[\"measures\"][\"0\"]", "as": "measures.0" }, { "type": "formula", "expr": "datum[\"markers\"] && datum[\"markers\"][\"0\"]", "as": "markers.0" } ] }, { "name": "row_domain", "source": "data_0", "transform": [{"type": "aggregate", "groupby": ["title"]}] }, { "name": "data_2", "source": "data_0", "transform": [ { "type": "stack", "groupby": ["title"], "field": "ranges\\.2", "sort": {"field": [], "order": []}, "as": ["ranges.2._start", "ranges.2._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"ranges.2\"]) && isFinite(+datum[\"ranges.2\"])" } ] }, { "name": "data_3", "source": "data_0", "transform": [ { "type": "stack", "groupby": ["title"], "field": "ranges\\.1", "sort": {"field": [], "order": []}, "as": ["ranges.1._start", "ranges.1._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"ranges.1\"]) && isFinite(+datum[\"ranges.1\"])" } ] }, { "name": "data_4", "source": "data_0", "transform": [ { "type": "stack", "groupby": ["title"], "field": "ranges\\.0", "sort": {"field": [], "order": []}, "as": ["ranges.0._start", "ranges.0._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"ranges.0\"]) && isFinite(+datum[\"ranges.0\"])" } ] }, { "name": "data_5", "source": "data_0", "transform": [ { "type": "stack", "groupby": ["title"], "field": "measures\\.1", "sort": {"field": [], "order": []}, "as": ["measures.1._start", "measures.1._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"measures.1\"]) && isFinite(+datum[\"measures.1\"])" } ] }, { "name": "data_6", "source": "data_0", "transform": [ { "type": "stack", "groupby": ["title"], "field": "measures\\.0", "sort": {"field": [], "order": []}, "as": ["measures.0._start", "measures.0._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"measures.0\"]) && isFinite(+datum[\"measures.0\"])" } ] }, { "name": "data_7", "source": "data_0", "transform": [ { "type": "filter", "expr": "isValid(datum[\"markers.0\"]) && isFinite(+datum[\"markers.0\"])" } ] } ], "signals": [ {"name": "child_width", "value": 200}, {"name": "child_height", "value": 20} ], "layout": {"padding": 10, "columns": 1, "bounds": "full", "align": "all"}, "marks": [ { "name": "row_header", "type": "group", "role": "row-header", "from": {"data": "row_domain"}, "sort": {"field": "datum[\"title\"]", "order": "ascending"}, "title": { "text": { "signal": "isValid(parent[\"title\"]) ? parent[\"title\"] : \"\"+parent[\"title\"]" }, "orient": "left", "style": "guide-label", "frame": "group", "baseline": "middle", "align": "right", "angle": 0, "offset": 10 }, "encode": {"update": {"height": {"signal": "child_height"}}} }, { "name": "cell", "type": "group", "style": "cell", "from": { "facet": {"name": "facet", "data": "data_0", "groupby": ["title"]} }, "sort": {"field": ["datum[\"title\"]"], "order": ["ascending"]}, "data": [ { "source": "facet", "name": "data_0", "transform": [ { "type": "stack", "groupby": [], "field": "ranges\\.2", "sort": {"field": [], "order": []}, "as": ["ranges.2._start", "ranges.2._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"ranges.2\"]) && isFinite(+datum[\"ranges.2\"])" } ] }, { "source": "facet", "name": "data_1", "transform": [ { "type": "stack", "groupby": [], "field": "ranges\\.1", "sort": {"field": [], "order": []}, "as": ["ranges.1._start", "ranges.1._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"ranges.1\"]) && isFinite(+datum[\"ranges.1\"])" } ] }, { "source": "facet", "name": "data_2", "transform": [ { "type": "stack", "groupby": [], "field": "ranges\\.0", "sort": {"field": [], "order": []}, "as": ["ranges.0._start", "ranges.0._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"ranges.0\"]) && isFinite(+datum[\"ranges.0\"])" } ] }, { "source": "facet", "name": "data_3", "transform": [ { "type": "stack", "groupby": [], "field": "measures\\.1", "sort": {"field": [], "order": []}, "as": ["measures.1._start", "measures.1._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"measures.1\"]) && isFinite(+datum[\"measures.1\"])" } ] }, { "source": "facet", "name": "data_4", "transform": [ { "type": "stack", "groupby": [], "field": "measures\\.0", "sort": {"field": [], "order": []}, "as": ["measures.0._start", "measures.0._end"], "offset": "zero" }, { "type": "filter", "expr": "isValid(datum[\"measures.0\"]) && isFinite(+datum[\"measures.0\"])" } ] }, { "source": "facet", "name": "data_5", "transform": [ { "type": "filter", "expr": "isValid(datum[\"markers.0\"]) && isFinite(+datum[\"markers.0\"])" } ] } ], "encode": { "update": { "width": {"signal": "child_width"}, "height": {"signal": "child_height"} } }, "signals": [{"name": "height", "update": "child_height"}], "marks": [ { "name": "child_layer_0_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_0"}, "encode": { "update": { "fill": {"value": "#eee"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"ranges[2]: \" + (format(datum[\"ranges.2\"], \"\"))" }, "x": {"scale": "child_x", "field": "ranges\\.2\\._end"}, "x2": {"scale": "child_x", "field": "ranges\\.2\\._start"}, "yc": {"signal": "child_height", "mult": 0.5}, "height": {"value": 18} } } }, { "name": "child_layer_1_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_1"}, "encode": { "update": { "fill": {"value": "#ddd"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"ranges[1]: \" + (format(datum[\"ranges.1\"], \"\"))" }, "x": {"scale": "child_x", "field": "ranges\\.1\\._end"}, "x2": {"scale": "child_x", "field": "ranges\\.1\\._start"}, "yc": {"signal": "child_height", "mult": 0.5}, "height": {"value": 18} } } }, { "name": "child_layer_2_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_2"}, "encode": { "update": { "fill": {"value": "#ccc"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"ranges[0]: \" + (format(datum[\"ranges.0\"], \"\"))" }, "x": {"scale": "child_x", "field": "ranges\\.0\\._end"}, "x2": {"scale": "child_x", "field": "ranges\\.0\\._start"}, "yc": {"signal": "child_height", "mult": 0.5}, "height": {"value": 18} } } }, { "name": "child_layer_3_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_3"}, "encode": { "update": { "fill": {"value": "lightsteelblue"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"measures[1]: \" + (format(datum[\"measures.1\"], \"\"))" }, "x": {"scale": "child_x", "field": "measures\\.1\\._end"}, "x2": {"scale": "child_x", "field": "measures\\.1\\._start"}, "yc": {"signal": "child_height", "mult": 0.5}, "height": {"value": 10} } } }, { "name": "child_layer_4_marks", "type": "rect", "style": ["bar"], "from": {"data": "data_4"}, "encode": { "update": { "fill": {"value": "steelblue"}, "ariaRoleDescription": {"value": "bar"}, "description": { "signal": "\"measures[0]: \" + (format(datum[\"measures.0\"], \"\"))" }, "x": {"scale": "child_x", "field": "measures\\.0\\._end"}, "x2": {"scale": "child_x", "field": "measures\\.0\\._start"}, "yc": {"signal": "child_height", "mult": 0.5}, "height": {"value": 10} } } }, { "name": "child_layer_5_marks", "type": "rect", "style": ["tick"], "from": {"data": "data_5"}, "encode": { "update": { "opacity": {"value": 0.7}, "fill": {"value": "black"}, "ariaRoleDescription": {"value": "tick"}, "description": { "signal": "\"markers[0]: \" + (format(datum[\"markers.0\"], \"\"))" }, "xc": {"scale": "child_x", "field": "markers\\.0"}, "yc": {"signal": "child_height", "mult": 0.5}, "height": {"value": 15}, "width": {"value": 2} } } } ], "scales": [ { "name": "child_x", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "ranges\\.2\\._start"}, {"data": "data_0", "field": "ranges\\.2\\._end"}, {"data": "data_1", "field": "ranges\\.1\\._start"}, {"data": "data_1", "field": "ranges\\.1\\._end"}, {"data": "data_2", "field": "ranges\\.0\\._start"}, {"data": "data_2", "field": "ranges\\.0\\._end"}, {"data": "data_3", "field": "measures\\.1\\._start"}, {"data": "data_3", "field": "measures\\.1\\._end"}, {"data": "data_4", "field": "measures\\.0\\._start"}, {"data": "data_4", "field": "measures\\.0\\._end"}, {"data": "data_5", "field": "markers\\.0"} ] }, "range": [0, {"signal": "child_width"}], "nice": false, "zero": true } ], "axes": [ { "scale": "child_x", "orient": "bottom", "grid": true, "tickCount": {"signal": "ceil(child_width/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "child_x", "orient": "bottom", "grid": false, "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(child_width/40)"}, "zindex": 0 } ] } ] }