viewof view2 = embed({
width: 420,
height: 670,
data: [
{
name: "centroids",
url:
"https://gicentre.github.io/data/uk/constituencySpacedCentroidsWithSpacers.csv",
format: { type: "csv", parse: "auto" },
transform: [
{
type: "geopoint",
projection: "projection",
fields: ["longitude", "latitude"]
},
{
type: "voronoi",
x: "x",
y: "y",
size: [{ signal: "width" }, { signal: "height" }]
}
]
}
],
projections: [
{
name: "projection",
type: "transverseMercator",
scale: 3700,
translate: [320, 3855]
}
],
scales: [{ name: "cScale", type: "ordinal", range: "category" }],
marks: [
{
type: "path",
from: { data: "centroids" },
encode: {
enter: {
path: { field: "path" },
fill: [
{ test: "datum.region == 0", value: "transparent" },
{ scale: "cScale", field: "region" }
]
}
}
}
]
})