Public
Edited
Feb 5, 2024
Insert cell
Insert cell
{
const svg = viz.create();

const data = nuovoGeoJson.features.map((d) => d.properties.Valore);
const choro = viz.tool.choro(data, {
method: "jenks",
nb: 5,
precision: 0,
colors: "PinkYl"
});

svg.path({ data: naz_rewind, fill: "#9b577d" });

svg.path({
data: nuovoGeoJson,
fill: (d) => choro.colorize(d.properties.Valore)
});

// We adda a legend
svg.legend.choro_horizontal({
pos: [400, 380],
...choro,
title: "Numero di persone"
});

return svg.render();
}
Insert cell
Insert cell
viz = require("geoviz@0.4.6")
Insert cell
import { style, world, disclaimer } from "@neocartocnrs/geoviz-appendix"
Insert cell
nazionalita = FileAttachment("tmp.geojson").json()
Insert cell
naz_rewind = viz.tool.rewind(nazionalita)
Insert cell
// Crea una copia profonda del GeoJSON originale
nuovoGeoJson = JSON.parse(JSON.stringify(naz_rewind))
Insert cell
(nuovoGeoJson.features = nuovoGeoJson.features.map((feature) => {
// Controlla se il campo "valore" esiste e se è uguale a 0
if (feature.properties.Valore === 0) {
// Imposta il campo "valore" a null
feature.properties.Valore = null;
}
return feature;
}))
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