Public
Edited
Mar 26
3 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
projection: ({ width, height }) =>
d3_composite
.geoConicConformalSpain()
.fitSize([width, height], zoom > 0 ? dataForTable : spainPostalMap),
width: width,
height: width * 0.45,
marks: [
Plot.frame({ marginBottom: 16, stroke: "none", fill: "#333332" }),
Plot.raster(fullData, { x: "x", y: "y", fill: "id" }),
// Plot.raster(filteredData, { x: "x", y: "y", fill: "id" }),
Plot.text(numbersOverlay, { x: "x", y: "y", dy: -10, text: "text", fill: "id" }),
Plot.dot(dotOverlay, { x: "x", y: "y", fill: "id", r: postalCode.length / 2 }),
Plot.text(textOverlay, { x: "x", y: "y", dy: -10, text: "name", fill: "id", fontSize: 14 })
]
})
Insert cell
Insert cell
Insert cell
dataForTable = ({
type: "FeatureCollection",
features: spainPostalMap.features.filter(item => item.properties.COD_POSTAL.contains(postalCodeForTable))
})

Insert cell
fullData = spainPostalMapCentroids
.map((d) => ({
x: d.coords[0],
y: d.coords[1],
id: '#8c8b64'
}));
Insert cell
Insert cell
filteredData = spainPostalMapCentroids
.filter((d) => d.properties.COD_POSTAL.startsWith(postalCode))
.map((d) => ({
x: d.coords[0],
y: d.coords[1],
id: postalCode.length > 0 ? "#eeeeee" : "#8c8b64",
text: d.properties.COD_POSTAL.slice(postalCode.length - 5),
name: d.properties.textData ? `${d.properties.textData.entidad_singular_nombre}, ${d.properties.textData.municipio_nombre}` : ''
}))
Insert cell
Insert cell
numbersOverlay = postalCode.length >= 3 && postalCode.length < 5 ? filteredData : []
Insert cell
textOverlay = postalCode.length === 5 ? filteredData : []
Insert cell
dotOverlay = postalCode.length > 1 ? filteredData : []
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more