getMapForProperty = (property, title) =>
vl
.layer(
vl
.markGeoshape({
stroke: "#706545",
strokeWidth: 0.5
})
.transform(
vl
.lookup("id")
.from(
vl
.data(countryData)
.key("isoCode")
.fields("veganPercent", "vegetarianPercent")
)
)
.data(vl.topojson(worldMinusAntarctica).feature("countries"))
.encode(
vl
.color()
.fieldQ(property)
.scale({ domain: [0, maxPercentage] })
.legend({ orient: "bottom-left", format: ".0%", title })
.if(`datum.${property} == 0`, vl.value("#d1dbdd")),
vl.tooltip([
vl.fieldN("properties.name"),
vl.fieldQ("veganPercent"),
vl.fieldQ("vegetarianPercent")
])
)
)
.background("transparent")
.width(width - 150)
.height(500)
.config({ view: { stroke: null } })
.project(vl.projection("equalEarth"))
.render({ renderer: "svg" })