{ "$schema": "https://vega.github.io/schema/vega/v3.0.json", "config":{"background":"#ffffff"}, "width": 800, "height": 480, "autosize": "none", "projections": [ { "name": "projection", "type": "albersUsa", "scale": 900, "translate": [{"signal": "width / 2"},{"signal": "height / 2"}] } ], "data": [ { "name": "states", "url": "data/us-10m.json", "format": {"type": "topojson","feature": "states"}, "transform": [{"type": "geopath","projection": "projection"}] }, { "name": "zipcodes", "url": "data/zip_codes_states.csv", "format": { "type": "csv", "parse": { "longitude": "number", "latitude": "number", "zip_code": "string" } }, "transform": [ { "type": "formula", "expr": "substring(datum.zip_code, 0, 1)", "as": "digit" }, { "type": "geopoint", "projection": "projection", "fields": ["longitude","latitude"] } ] } ], "scales": [ { "name": "color", "type": "ordinal", "domain": {"data": "zipcodes","field": "digit", "sort": true}, "range": "category" } ], "legends": [{"fill": "color", "orient": "top-right"}], "marks": [ { "type": "path", "from": {"data": "states"}, "encode": { "enter": { "strokeWidth": {"value": "1"}, "stroke": {"value": "#fff"}, "fill": {"value": "#ddd"}, "path": {"field": "path"} } } }, { "type": "symbol", "interactive": false, "from": {"data": "zipcodes"}, "encode": { "enter": { "size": {"value": 2}, "shape": {"value": "circle"}, "fill": {"scale": "color","field": "digit"} }, "update": {"x": {"field": "x"},"y": {"field": "y"}} } } ] }