{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "height": 200, "style": "cell", "data": [ { "name": "source_0", "values": [ {"rank": "1"}, {"rank": "2", "options": {"price": 16}}, {"rank": "3", "options": {"price": 17}} ] }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "formula", "expr": "datum[\"options\"] && datum[\"options\"][\"price\"]", "as": "options.price" }, {"type": "filter", "expr": "datum.options != null && datum.options.price != null"} ] } ], "signals": [ {"name": "x_step", "value": 20}, { "name": "width", "update": "bandspace(domain('x').length, 1, 0.5) * x_step" } ], "marks": [ { "name": "marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"rank\"]"}, "from": {"data": "data_0"}, "encode": { "update": { "stroke": {"value": "#4c78a8"}, "description": { "signal": "\"rank: \" + (isValid(datum[\"rank\"]) ? datum[\"rank\"] : \"\"+datum[\"rank\"]) + \"; options.price: \" + (format(datum[\"options.price\"], \"\"))" }, "x": {"scale": "x", "field": "rank"}, "y": {"scale": "y", "field": "options\\.price"}, "defined": { "signal": "isValid(datum[\"options.price\"]) && isFinite(+datum[\"options.price\"])" } } } } ], "scales": [ { "name": "x", "type": "point", "domain": {"data": "data_0", "field": "rank", "sort": true}, "range": {"step": {"signal": "x_step"}}, "padding": 0.5 }, { "name": "y", "type": "linear", "domain": {"data": "data_0", "field": "options\\.price"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true } ], "axes": [ { "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": "rank", "labelAlign": "right", "labelAngle": 270, "labelBaseline": "middle", "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "options.price", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ] }