{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "Average Stock prices of 5 Tech Companies.", "background": "white", "padding": 5, "width": 20, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/stocks.csv", "format": {"type": "csv"}, "transform": [ { "type": "aggregate", "groupby": ["symbol"], "ops": ["mean"], "fields": ["price"], "as": ["mean_price"] }, { "type": "filter", "expr": "isValid(datum[\"mean_price\"]) && isFinite(+datum[\"mean_price\"])" } ] } ], "marks": [ { "name": "marks", "type": "rule", "style": ["rule"], "from": {"data": "source_0"}, "encode": { "update": { "stroke": {"scale": "color", "field": "symbol"}, "description": { "signal": "\"Mean of price: \" + (format(datum[\"mean_price\"], \"\")) + \"; symbol: \" + (isValid(datum[\"symbol\"]) ? datum[\"symbol\"] : \"\"+datum[\"symbol\"])" }, "x": {"field": {"group": "width"}}, "x2": {"value": 0}, "y": {"scale": "y", "field": "mean_price"}, "strokeWidth": {"value": 2} } } } ], "scales": [ { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "mean_price"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "color", "type": "ordinal", "domain": {"data": "source_0", "field": "symbol", "sort": true}, "range": "category" } ], "axes": [ { "scale": "y", "orient": "left", "grid": true, "tickCount": {"signal": "ceil(height/40)"}, "domain": false, "labels": false, "aria": false, "maxExtent": 0, "minExtent": 0, "ticks": false, "zindex": 0 }, { "scale": "y", "orient": "left", "grid": false, "title": "Mean of price", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 } ], "legends": [{"stroke": "color", "symbolType": "stroke", "title": "symbol"}] }