Public
Edited
Nov 18, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bertin = require("bertin")
Insert cell
Insert cell
Insert cell
Insert cell
geom = FileAttachment("geom.geojson").json()
Insert cell
data = FileAttachment("data.csv").csv({ typed: true })
Insert cell
Insert cell
Insert cell
bertin.match(geom, "ISO3", data, "id")
Insert cell
Insert cell
world = bertin.merge(geom, "ISO3", data, "id")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bertin.draw({
layers: [
{
geojson: world,
fill: "blue",
stroke: "green"
}
]
})
Insert cell
Insert cell
Insert cell
bertin.draw({
layers: [
{
type: "bubble",
geojson: world,
values: "pop", // <- données quantitatives absolues
fill: "red",
leg_x: 75,
leg_y: 250,
leg_round: -2
},
{
geojson: world,
fill: "#CCC"
}
]
})
Insert cell
Insert cell
Insert cell
bertin.draw({
layers: [
{
geojson: world,
fill: {
type: "choro",
values: "gdppc", // <- données quantitatives realtives
leg_x: 75,
leg_y: 250,
leg_round: -2
}
}
]
})
Insert cell
Insert cell
Insert cell
bertin.draw({
layers: [
{
geojson: world,
//strokeWidth: 10,
fill: {
type: "typo",
values: "region", // <- données qualitatives
leg_x: 75,
leg_y: 250
}
}
]
})
Insert cell
Insert cell
Insert cell
Insert cell
bertin.draw({
layers: [
// COUCHE 1
{
type: "bubble",
geojson: world,
values: "pop", // <- données quantitatives absolues
fill: "none",
stroke: "black",
strokeWidth: 1.5
},
//COUCHE 2
{
geojson: world,
fill: {
type: "typo",
values: "region" // <- données qualitatives
}
}
]
})
Insert cell
Insert cell
bertin.draw({
layers: [
{
type: "bubble",
geojson: world,
values: "pop", // <- données quantitatives absolues
stroke: {
type: "typo",
values: "region" // <- données qualitatives
},
fill: "none",
strokeWidth: 2
},
{
geojson: world,
fill: "#CCC"
}
]
})
Insert cell
Insert cell
bertin.draw({
params: { projection: "InterruptedSinusoidal" }, // Paramètres généraux (marges, projection, etc.)
layers: [
{ type: "header", text: "La population mondiale" }, // Titre
{ type: "footer", text: "Fait avec bertin.js", anchor: "middle" }, // Source
// COUCHE 1 (cercles)
{
type: "bubble",
geojson: world, // géometrie
values: "pop", // variable
fill: "#b566ac", // couleur des cercles
stroke: "white", // couleur de contour des cercles
strokeWidth: 0.5, // épaisseur
tooltip: ["$name", "$pop"], // Infobulle
leg_x: 100, // position de la légende (x)
leg_y: 250, // position de la légende (y)
leg_title: "Population des\npays en 2000", // Titre de la légende
leg_round: -3 // arrondi
},
// COUCHE 1 (pays)
{
geojson: world, // géométrie
fill: "white", // couleur de fond
stroke: "none", // cauleur de contour (aucun)
fillOpacity: 0.5 // Opacité
},
{ type: "graticule" }, // Lignes de latitude et longitude
{ type: "outline" } // coutour de la Terre dans la projection
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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