{ "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "data": [ { "name": "source_1", "url": "data/us-10m.json", "format": {"type": "topojson", "feature": "states"} }, { "name": "source_0", "url": "data/income.json", "format": {"type": "json"}, "transform": [ { "type": "lookup", "from": "source_1", "key": "id", "fields": ["id"], "as": ["geo"] }, {"type": "filter", "expr": "isValid(datum[\"geo\"])"}, {"type": "geojson", "geojson": "geo", "signal": "child_geojson_0"}, { "type": "filter", "expr": "isValid(datum[\"pct\"]) && isFinite(+datum[\"pct\"])" } ] }, { "name": "row_domain", "source": "source_0", "transform": [{"type": "aggregate", "groupby": ["group"]}] } ], "projections": [ { "name": "projection", "size": {"signal": "[child_width, child_height]"}, "fit": {"signal": "child_geojson_0"}, "type": "albersUsa" } ], "signals": [ {"name": "child_width", "value": 500}, {"name": "child_height", "value": 300} ], "layout": { "padding": 20, "offset": {"rowTitle": 10}, "columns": 1, "bounds": "full", "align": "all" }, "marks": [ { "name": "row-title", "type": "group", "role": "row-title", "title": { "text": "group", "orient": "left", "style": "guide-title", "offset": 10 } }, { "name": "row_header", "type": "group", "role": "row-header", "from": {"data": "row_domain"}, "sort": {"field": "datum[\"group\"]", "order": "ascending"}, "title": { "text": { "signal": "isValid(parent[\"group\"]) ? parent[\"group\"] : \"\"+parent[\"group\"]" }, "orient": "left", "style": "guide-label", "frame": "group", "offset": 10 }, "encode": {"update": {"height": {"signal": "child_height"}}} }, { "name": "cell", "type": "group", "from": { "facet": {"name": "facet", "data": "source_0", "groupby": ["group"]} }, "sort": {"field": ["datum[\"group\"]"], "order": ["ascending"]}, "encode": { "update": { "width": {"signal": "child_width"}, "height": {"signal": "child_height"} } }, "marks": [ { "name": "child_marks", "type": "shape", "style": ["geoshape"], "from": {"data": "facet"}, "encode": { "update": { "fill": {"scale": "color", "field": "pct"}, "ariaRoleDescription": {"value": "geoshape"}, "description": { "signal": "\"pct: \" + (format(datum[\"pct\"], \"\")) + \"; geo: \" + (isValid(datum[\"geo\"]) ? datum[\"geo\"] : \"\"+datum[\"geo\"])" } } }, "transform": [ { "type": "geoshape", "projection": "projection", "field": "datum[\"geo\"]" } ] } ] } ], "scales": [ { "name": "color", "type": "linear", "domain": {"data": "source_0", "field": "pct"}, "range": "heatmap", "interpolate": "hcl", "zero": false } ], "legends": [ { "fill": "color", "gradientLength": {"signal": "clamp(child_height, 64, 200)"}, "title": "pct" } ] }