vl.spec({
data: { values: countiesData },
width: width,
height: height,
transform: [{
lookup: 'id',
from: {
data: {values: waPopulation},
key: 'GEOID_TIGER',
fields: ['Census2020'],
}
}, {
calculate: "geoCentroid(null, datum)",
as: "centroid"
}, {
calculate: "datum.centroid[0]",
as: "lon"
}, {
calculate: "datum.centroid[1]",
as: "lat"
}],
layer: [{
mark: { type: 'geoshape' },
encoding: {
color: {
value: "transparent"
},
stroke: {
value: "black"
}
},
projection: { type: 'mercator' },
}, {
"mark": "circle",
"encoding": {
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "Census2020",
"type": "quantitative"
}
}
}],
})
.render()