{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Horizon Graph with 2 layers. (See https://idl.cs.washington.edu/papers/horizon/ for more details on Horizon Graphs.)", "background": "white", "padding": 5, "width": 300, "height": 50, "style": "cell", "data": [ { "name": "source_0", "values": [ {"x": 1, "y": 28}, {"x": 2, "y": 55}, {"x": 3, "y": 43}, {"x": 4, "y": 91}, {"x": 5, "y": 81}, {"x": 6, "y": 53}, {"x": 7, "y": 19}, {"x": 8, "y": 87}, {"x": 9, "y": 52}, {"x": 10, "y": 48}, {"x": 11, "y": 24}, {"x": 12, "y": 49}, {"x": 13, "y": 87}, {"x": 14, "y": 66}, {"x": 15, "y": 17}, {"x": 16, "y": 27}, {"x": 17, "y": 68}, {"x": 18, "y": 16}, {"x": 19, "y": 49}, {"x": 20, "y": 15} ] }, { "name": "data_0", "source": "source_0", "transform": [ {"type": "formula", "expr": "toNumber(datum[\"x\"])", "as": "x"} ] }, { "name": "data_1", "source": "data_0", "transform": [{"type": "formula", "expr": "datum.y - 50", "as": "ny"}] } ], "marks": [ { "name": "layer_0_marks", "type": "area", "clip": true, "style": ["area"], "sort": {"field": "datum[\"x\"]"}, "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.6}, "orient": {"value": "vertical"}, "fill": {"value": "#4c78a8"}, "description": { "signal": "\"x: \" + (format(datum[\"x\"], \"\")) + \"; y: \" + (format(datum[\"y\"], \"\"))" }, "x": {"scale": "x", "field": "x"}, "y": {"scale": "y", "field": "y"}, "y2": {"scale": "y", "value": 0}, "defined": { "signal": "isValid(datum[\"x\"]) && isFinite(+datum[\"x\"]) && isValid(datum[\"y\"]) && isFinite(+datum[\"y\"])" } } } }, { "name": "layer_1_marks", "type": "area", "clip": true, "style": ["area"], "sort": {"field": "datum[\"x\"]"}, "from": {"data": "data_1"}, "encode": { "update": { "orient": {"value": "vertical"}, "fill": {"value": "#4c78a8"}, "opacity": {"value": 0.3}, "description": { "signal": "\"x: \" + (format(datum[\"x\"], \"\")) + \"; ny: \" + (format(datum[\"ny\"], \"\"))" }, "x": {"scale": "x", "field": "x"}, "y": {"scale": "y", "field": "ny"}, "y2": {"scale": "y", "value": 0}, "defined": { "signal": "isValid(datum[\"x\"]) && isFinite(+datum[\"x\"]) && isValid(datum[\"ny\"]) && isFinite(+datum[\"ny\"])" } } } } ], "scales": [ { "name": "x", "type": "linear", "domain": { "fields": [ {"data": "data_0", "field": "x"}, {"data": "data_1", "field": "x"} ] }, "range": [0, {"signal": "width"}], "nice": false, "zero": false }, { "name": "y", "type": "linear", "domain": [0, 50], "range": [{"signal": "height"}, 0], "zero": true } ], "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": "y", "orient": "left", "gridScale": "x", "grid": true, "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": "x", "labelFlush": true, "labelOverlap": true, "tickCount": {"signal": "ceil(width/40)"}, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "y", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "config": {"style": {"area": {"interpolate": "monotone"}}} }