embedWithSpecificVersions(
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 650,
"height": 450,
"padding": {"top": 0, "left": 0, "right": 0, "bottom": 0},
"autosize": "none",
"data": [
{
"name": "vPop",
"values": populations
},
{
"name": "MP",
"values": vanMP,
"format": {"type": "json", "property": "features"},
"transform": [
{
"type": "geopath",
"projection": "projection"
},
{
"type": "lookup",
"from": "vPop", "key": "Area",
"fields": ["properties.NAME"], "as": ["Population"]
}
]
}
],
"projections": [
{
name: "projection",
type: "mercator",
scale: 200000,
center: d3.geoCentroid(vanMP)
}
],
"signals": [
{
"name": "hover", "init": null,
"streams": [
{"type": "shape:mouseover", "expr": "datum"},
{"type": "shape:mouseout", "expr": "null"}
]
},
{
"name": "title", "init": null,
"streams": [{
"type": "hover",
"expr": "hover ? hover.NAME"
}]
}
],
"marks": [
{
"type": "shape",
"from": {"data": "MP"},
"encode":
{
"enter":
{
"path": {"field": "layout_path"},
"fill": {"value": "#aaaaaa"},
"stroke": {"value": "black"},
"tooltip": {"signal": "{'Local Area': datum.properties.NAME, 'Population': datum.Population.Population}"}
},
"update":
{
"path": {"field": "path"},
"stroke": {"value": "black"},
"fill": { "value": "#aaaaaa"},
"zindex": {"value": 0}
},
"hover": {
"strokeWidth": {"value": 1},
"stroke": {"value": "firebrick"},
"zindex": {"value": 1},
"fill": {"value": "red"}
},
"exit":
{
"stroke": {"value": "white"}
}
},
"transform":
[
{ "type": "geoshape", "projection": "projection" }
]
},
{
"type": "text",
"interactive": false,
"encode":
{
"enter":
{
"x": {"value": 895},
"y": {"value": 0},
"fill": {"value": "black"},
"fontSize": {"value": 20},
"align": {"value": "right"}
},
"update":
{
"text": {"signal": "title"}
}
}
}
]
})