viewof filter_map = embed(
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"config": {"view": {"stroke": null}},
"title": {
"text": "Select State from Dropdown to Change View",
"subtitle" : "(Hover on Map for more details)",
"anchor": "center",
"fontSize" : "16",
"zindex" : "1"
},
"width": 750,
"height": 400,
"data": {"values":geo_data, "format": {"type": "topojson","feature": "counties"}},
"layer":
[
{
"params": [
{"name": "Select",
"select": {"type": "point", "fields": ["STATE"]},
"value": 'VA',
"bind": {
"input": "select",
"options":
[
'AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA',
'HI','ID','IL','IN','IA','KS','KY','LA','ME','MD',
'MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ',
'NM','NY','NC','ND','OH','OK','OR','PA','RI','SC',
'SD','TN','TX','UT','VT','VA','WA','WV','WI','WY'
],
"labels":
[
'AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA',
'HI','ID','IL','IN','IA','KS','KY','LA','ME','MD',
'MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ',
'NM','NY','NC','ND','OH','OK','OR','PA','RI','SC',
'SD','TN','TX','UT','VT','VA','WA','WV','WI','WY'
],
"name": "State Selection: "
}
}
],
"transform":
[
{"lookup": "id", "from": {"data": {"values":base_data}, "key": "FIPS_NUM",
"fields": ["BIVARIATE_BIN", "COUNTY_NAME","STATE","MEDICARE_RATE","RESIDENTIAL_RATE"]}},
{"filter": {"param":"Select"}}
],
"projection": {"type": "mercator"},
"mark": {"type": "geoshape", "tooltip": true},
"encoding": {
"color": {
"field": "BIVARIATE_BIN", "type": "nominal",
"scale": {"domain": ["A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3"],
"range": ["#e8e8e8", "#ace4e4", "#5ac8c8", "#dfb0d6", "#a5add3", "#5698b9", "#be64ac", "#8c62aa", "#3b4994"]},
"legend": null
},
"tooltip": [
{"field": "BIVARIATE_BIN", "type": "nominal", "title": "Choropleth Code: "},
{"field": "COUNTY_NAME", "type": "nominal", "title": "County: "},
{"field": "STATE", "type": "nominal", "title": "State: "},
{"field": "MEDICARE_RATE", "type": "quantitative", "format": "~p", "title": "Medicare Rate: "},
{"field": "RESIDENTIAL_RATE", "type": "quantitative", "format": "~p", "title": "% Energy Residential Buildings: "}
]
}
}
,{
"data": {
"values": [
{"x": 1.01, "y": 0.5, "img": "https://raw.githubusercontent.com/aj-broderick/aj-broderick.github.io/main/images/cs625project_choropleth_legend.png"}
]
},
"mark": {"type": "image", "width": 185, "height": 185, "align" : "left"},
"encoding": {
"x": {"field": "x", "type": "quantitative",
"scale": {"domain": [0, 1]}, "axis": {"title": false, "labels": false, "domain": false, "grid": false, "ticks": false}},
"y": {"field": "y", "type": "quantitative",
"scale": {"domain": [0, 1]}, "axis": {"title": false, "labels": false, "domain": false, "grid": false, "ticks": false}},
"url": {"field": "img", "type": "nominal"}
}
}
]
}
)