Public
Edited
Mar 12, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viz.spike({
height: 100,
width: 40,
fill: "#38896F",
stroke: "#38896F"
})
Insert cell
Insert cell
viz.plot({
type: "spike",
height: 100,
width: 40,
fill: "#38896F",
stroke: "#38896F"
})
Insert cell
The <mark>**`straight`**</mark> attribute allow to customize the curve (0 = curved ; 1 = straight).
Insert cell
viewof straight = Inputs.range([0, 1], { label: "straight", step: 0.05 })
Insert cell
viz.spike({
height: 100,
width: 40,
fill: "#38896F",
stroke: "#38896F",
straight
})
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" });

// Spike
svg.spike({
pos: position,
fill: "#38896F",
stroke: "#38896F"
});

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

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

// Spike
svg.spike({
coords: "geo",
pos: mumbai,
fill: "#38896F",
stroke: "#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" });

// Spikes
svg.spike({
data: world,
width: 10,
stroke: "#38896F",
straight: 0.5,
height: 10,
fill: "#38896F"
});

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

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

// Spikes
svg.spike({
data: world,
width: 10,
k,
fillOpacity: 1,
stroke: "#38896F",
straight: 0.5,
height: "pop",
fill: "#38896F",
tip: true
});

// Render
return svg.render();
}
Insert cell
## 4 - Legends
Insert cell
Insert cell
viz.legend.spikes({ spike_stroke: "#38896F", title: "Number of inhabitants" })
Insert cell
Insert cell
viz.legend.spikes({
data: world.features.map((d) => d.properties.pop),
values_round: 0,
spike_stroke: "#38896F"
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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