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

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