{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Line chart with a dashed part created by drawing multiple connecting lines. Note that the data source contains the data point at (E, 81) twice.", "background": "white", "padding": 5, "height": 200, "style": "cell", "data": [ { "name": "source_0", "values": [ {"a": "A", "b": 28, "predicted": false}, {"a": "B", "b": 55, "predicted": false}, {"a": "D", "b": 91, "predicted": false}, {"a": "E", "b": 81, "predicted": false}, {"a": "E", "b": 81, "predicted": true}, {"a": "G", "b": 19, "predicted": true}, {"a": "H", "b": 87, "predicted": true} ] } ], "signals": [ {"name": "x_step", "value": 20}, { "name": "width", "update": "bandspace(domain('x').length, 1, 0.5) * x_step" } ], "marks": [ { "name": "pathgroup", "type": "group", "from": { "facet": { "name": "faceted_path_main", "data": "source_0", "groupby": ["predicted"] } }, "encode": { "update": { "width": {"field": {"group": "width"}}, "height": {"field": {"group": "height"}} } }, "marks": [ { "name": "marks", "type": "line", "style": ["line"], "sort": {"field": "datum[\"a\"]"}, "from": {"data": "faceted_path_main"}, "encode": { "update": { "stroke": {"value": "#4c78a8"}, "strokeDash": {"scale": "strokeDash", "field": "predicted"}, "description": { "signal": "\"a: \" + (isValid(datum[\"a\"]) ? datum[\"a\"] : \"\"+datum[\"a\"]) + \"; b: \" + (format(datum[\"b\"], \"\")) + \"; predicted: \" + (isValid(datum[\"predicted\"]) ? datum[\"predicted\"] : \"\"+datum[\"predicted\"])" }, "x": {"scale": "x", "field": "a"}, "y": {"scale": "y", "field": "b"}, "defined": { "signal": "isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])" } } } } ] } ], "scales": [ { "name": "x", "type": "point", "domain": {"data": "source_0", "field": "a", "sort": true}, "range": {"step": {"signal": "x_step"}}, "padding": 0.5 }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "b"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "strokeDash", "type": "ordinal", "domain": {"data": "source_0", "field": "predicted", "sort": true}, "range": [[1, 0], [4, 2], [2, 1], [1, 1], [1, 2, 4, 2]] } ], "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": "a", "labelAlign": "right", "labelAngle": 270, "labelBaseline": "middle", "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "b", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "legends": [ { "strokeDash": "strokeDash", "symbolType": "stroke", "title": "predicted", "encode": {"symbols": {"update": {"stroke": {"value": "#4c78a8"}}}} } ] }