{ "$schema": "https://vega.github.io/schema/vega/v5.json", "description": "the population per state, engineers per state, and hurricanes per state", "background": "white", "padding": 5, "width": 500, "data": [ { "name": "source_0", "url": "data/population_engineers_hurricanes.csv", "format": {"type": "csv"} }, { "name": "source_1", "url": "data/us-10m.json", "format": {"type": "topojson", "feature": "states"} }, { "name": "data_0", "source": "source_0", "transform": [ { "type": "lookup", "from": "source_1", "key": "id", "fields": ["id"], "as": ["geo"] }, {"type": "filter", "expr": "isValid(datum[\"geo\"])"}, { "type": "geojson", "geojson": "geo", "signal": "child__row_population_geojson_0" }, { "type": "filter", "expr": "isValid(datum[\"population\"]) && isFinite(+datum[\"population\"])" } ] }, { "name": "data_1", "source": "source_0", "transform": [ { "type": "lookup", "from": "source_1", "key": "id", "fields": ["id"], "as": ["geo"] }, {"type": "filter", "expr": "isValid(datum[\"geo\"])"}, { "type": "geojson", "geojson": "geo", "signal": "child__row_engineers_geojson_0" }, { "type": "filter", "expr": "isValid(datum[\"engineers\"]) && isFinite(+datum[\"engineers\"])" } ] }, { "name": "data_2", "source": "source_0", "transform": [ { "type": "lookup", "from": "source_1", "key": "id", "fields": ["id"], "as": ["geo"] }, {"type": "filter", "expr": "isValid(datum[\"geo\"])"}, { "type": "geojson", "geojson": "geo", "signal": "child__row_hurricanes_geojson_0" }, { "type": "filter", "expr": "isValid(datum[\"hurricanes\"]) && isFinite(+datum[\"hurricanes\"])" } ] } ], "projections": [ { "name": "projection", "size": {"signal": "[width, childHeight]"}, "fit": { "signal": "[child__row_population_geojson_0, child__row_engineers_geojson_0, child__row_hurricanes_geojson_0]" }, "type": "albersUsa" } ], "signals": [{"name": "childHeight", "value": 300}], "layout": {"padding": 20, "columns": 1, "bounds": "full", "align": "all"}, "marks": [ { "type": "group", "name": "child__row_population_group", "encode": { "update": { "width": {"signal": "width"}, "height": {"signal": "childHeight"} } }, "marks": [ { "name": "child__row_population_marks", "type": "shape", "style": ["geoshape"], "from": {"data": "data_0"}, "encode": { "update": { "fill": { "scale": "child__row_population_color", "field": "population" }, "ariaRoleDescription": {"value": "geoshape"}, "description": { "signal": "\"population: \" + (format(datum[\"population\"], \"\")) + \"; geo: \" + (isValid(datum[\"geo\"]) ? datum[\"geo\"] : \"\"+datum[\"geo\"])" } } }, "transform": [ { "type": "geoshape", "projection": "projection", "field": "datum[\"geo\"]" } ] } ], "legends": [ { "fill": "child__row_population_color", "gradientLength": {"signal": "clamp(childHeight, 64, 200)"}, "title": "population" } ] }, { "type": "group", "name": "child__row_engineers_group", "encode": { "update": { "width": {"signal": "width"}, "height": {"signal": "childHeight"} } }, "marks": [ { "name": "child__row_engineers_marks", "type": "shape", "style": ["geoshape"], "from": {"data": "data_1"}, "encode": { "update": { "fill": { "scale": "child__row_engineers_color", "field": "engineers" }, "ariaRoleDescription": {"value": "geoshape"}, "description": { "signal": "\"engineers: \" + (format(datum[\"engineers\"], \"\")) + \"; geo: \" + (isValid(datum[\"geo\"]) ? datum[\"geo\"] : \"\"+datum[\"geo\"])" } } }, "transform": [ { "type": "geoshape", "projection": "projection", "field": "datum[\"geo\"]" } ] } ], "legends": [ { "fill": "child__row_engineers_color", "gradientLength": {"signal": "clamp(childHeight, 64, 200)"}, "title": "engineers" } ] }, { "type": "group", "name": "child__row_hurricanes_group", "encode": { "update": { "width": {"signal": "width"}, "height": {"signal": "childHeight"} } }, "marks": [ { "name": "child__row_hurricanes_marks", "type": "shape", "style": ["geoshape"], "from": {"data": "data_2"}, "encode": { "update": { "fill": { "scale": "child__row_hurricanes_color", "field": "hurricanes" }, "ariaRoleDescription": {"value": "geoshape"}, "description": { "signal": "\"hurricanes: \" + (format(datum[\"hurricanes\"], \"\")) + \"; geo: \" + (isValid(datum[\"geo\"]) ? datum[\"geo\"] : \"\"+datum[\"geo\"])" } } }, "transform": [ { "type": "geoshape", "projection": "projection", "field": "datum[\"geo\"]" } ] } ], "legends": [ { "fill": "child__row_hurricanes_color", "gradientLength": {"signal": "clamp(childHeight, 64, 200)"}, "title": "hurricanes" } ] } ], "scales": [ { "name": "child__row_population_color", "type": "linear", "domain": {"data": "data_0", "field": "population"}, "range": "heatmap", "interpolate": "hcl", "zero": false }, { "name": "child__row_engineers_color", "type": "linear", "domain": {"data": "data_1", "field": "engineers"}, "range": "heatmap", "interpolate": "hcl", "zero": false }, { "name": "child__row_hurricanes_color", "type": "linear", "domain": {"data": "data_2", "field": "hurricanes"}, "range": "heatmap", "interpolate": "hcl", "zero": false } ] }