Public
Edited
Dec 13, 2023
2 forks
Importers
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bertin.draw({
params: { projection: d3.geoBromley() },
layers: [
{
type: "bubble",
geojson: data,
values: "pop",
k: k,
fill: "#e368c0",
//fixmax: 10000000,
tooltip: [
"$country",
(d) => Math.round(d.properties.pop / 1000) + " million inh."
],
leg_round: 0,
leg_x: 100,
leg_y: 170,
leg_round: 0,
leg_divisor: 1000,
leg_title: "World Population\nin 2018 (million inh.)"
},
{
type: "missing",
geojson: data,
values: "pop",
leg_x: 500,
leg_y: 320
},
{
type: "layer",
geojson: countries,
fill: "#f5d482",
leg_x: 600,
leg_y: 320,
leg_text: "Countries"
},
{ type: "graticule" },
{ type: "outline" }
]
})
Insert cell
Insert cell
cities = d3
.csv(
"https://raw.githubusercontent.com/neocarto/resources/master/datasets/simplemaps_worldcities_basicv1.73/worldcities.csv"
)
.then((r) => r.filter((d) => +d.population > 1000000))
Insert cell
Insert cell
bertin.draw({
params: { projection: d3.geoBertin1953() },
layers: [
{
type: "bubble",
geojson: cities,
values: "population",
k: 17,
tooltip: ["$city", "$country"],
fill: "#5c7db8",
leg_x: 680,
leg_y: 410,
leg_round: 0,
leg_fontSize2: 7,
leg_title: `Number of inhabitants
in the world's largest cities`
},

{
type: "layer",
geojson: countries,
fill: "white",
fillOpacity: 0.5,
stroke: "none"
},
{ type: "graticule" },
{ type: "outline" }
]
})
Insert cell
Insert cell
tmp = FileAttachment("API_BN@1.CAB.XOKA.CD_DS2_en_csv_v2_3733806.csv")
.csv()
.then((d) =>
d.map((d) => ({
id: d["Country Code"],
name: d["Country Name"],
bop_2020: +d[2020] / 1000000000
}))
)
Insert cell
bop = bertin.merge(countries, "ISO3_CODE", tmp, "id")
Insert cell
bertin.draw({
params: { projection: d3.geoBromley() },
layers: [
{
type: "bubble",
geojson: bop,
values: "bop_2020",
k: k,
fill: {
type: "split",
values: "bop_2020",
colors: ["#F25842", "#4a7cd9"],
split: 0,
leg_x: 100,
leg_y: 300
},
tooltip: ["$name", "$bop_2020"],
leg_round: 0,
leg_x: 100,
leg_y: 170,
leg_round: -1,
leg_title: "Balance of payment,\n(in billion $ in 2020)"
},
{
type: "missing",
geojson: bop,
values: "bop_2020"
},
{
type: "layer",
geojson: countries,
fill: "#f5d482"
},
{ type: "graticule" },
{ type: "outline" }
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more