{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 200, "height": 200, "style": "cell", "data": [ { "name": "source_0", "url": "data/cars.json", "format": {"type": "json"}, "transform": [ {"type": "formula", "expr": "datum.Origin[0]", "as": "OriginInitial"}, { "type": "filter", "expr": "isValid(datum[\"Horsepower\"]) && isFinite(+datum[\"Horsepower\"]) && isValid(datum[\"Miles_per_Gallon\"]) && isFinite(+datum[\"Miles_per_Gallon\"])" } ] } ], "marks": [ { "name": "marks", "type": "text", "style": ["text"], "from": {"data": "source_0"}, "encode": { "update": { "fill": {"scale": "color", "field": "Origin"}, "x": { "value": 0, "offset": { "scale": "x", "field": "Horsepower" } }, "y": {"scale": "y", "field": "Miles_per_Gallon"}, "text": { "signal": "isValid(datum[\"OriginInitial\"]) ? datum[\"OriginInitial\"] : \"\"+datum[\"OriginInitial\"]" }, "align": {"value": "center"}, "baseline": {"value": "middle"} } } } ], "scales": [ { "name": "x", "type": "linear", "domain": [0, 300], "range": [0, {"signal": "width"}], "nice": true, "zero": true }, { "name": "y", "type": "linear", "domain": {"data": "source_0", "field": "Miles_per_Gallon"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true }, { "name": "color", "type": "ordinal", "domain": {"data": "source_0", "field": "Origin", "sort": true}, "range": "category" } ] }