Public
Edited
May 28, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viz.square({ fill: "#38896F", side: 50 })
Insert cell
Insert cell
viz.plot({ type: "square", side: 50, fill: "#38896F", angle: 45 })
Insert cell
Insert cell
position = [300, 100]
Insert cell
{
// Container
let svg = viz.create({
width: 500,
domain: world,
zoomable: true
});

// Basemap
svg.path({ datum: world, fill: "#CCC" });

// Square
svg.square({
pos: position,
angle: 45,
fill: "#38896F"
});

// Render
return svg.render();
}
Insert cell
Insert cell
abuja = [7.54, 9.19]
Insert cell
{
// Container
let svg = viz.create({
domain: world,
width: 500,
zoomable: true
});

// Basemap
svg.path({ datum: world, fill: "#CCC" });

// Square
svg.square({
coords: "geo",
angle: 45,
pos: abuja,

fill: "#38896F"
});

// Render

return svg.render();
}
Insert cell
Insert cell
Insert cell
{
// Container
let svg = viz.create({
width: 500,
zoomable: true,
domain: world
});

// Basemap
svg.path({ datum: world, fill: "#CCC" });

// Squares
svg.square({
data: world,
side: 10,
fill: "#38896F"
});

// Render
return svg.render();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
// Container
let svg = viz.create({
width: 500,
zoomable: "true",
domain: world
});

// Basemap
svg.path({ datum: world, fill: "#CCC" });

// Squares
svg.square({
data: world,
k: 20,
side: "pop",
angle,
fill: "#38896F"
});

// Render
return svg.render();
}
Insert cell
Insert cell
Insert cell
Insert cell
{
// Container
let svg = viz.create({
width: 500,
zoomable: true,
domain: world
});

// Basemap
svg.path({ datum: world, fill: "#CCC" });

// Circles
svg.square({
data: world,
side: (d) => gradsizes(d.properties.pop),
sort: (a, b) =>
d3.descending(Math.abs(+a.properties.pop), Math.abs(+b.properties.pop)),
fill: (d) => gradcol(d.properties.pop)
});

// Render
return svg.render();
}
Insert cell
Insert cell
Insert cell
viz.legend.squares({
data: world.features.map((d) => d.properties.pop),
values_factor: 1 / 1000000,
values_round: 0,
title: "Population",
subtitle: "(in million inh.)"
})
Insert cell
viz.legend.squares_nested({
data: world.features.map((d) => d.properties.pop),
values_factor: 1 / 1000000,
values_round: 0,
title: "Population",
subtitle: "(in million inh.)"
})
Insert cell
Insert cell
Insert cell
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