Public
Edited
Dec 2, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// values passed into divergingScale function
values = [d3.randomInt(0, pivot)(), d3.randomInt(0, max)(), d3.randomInt(pivot, max)()]
Insert cell
{
return html`
<style>
.radial {
width: ${width*0.8}px;
height: ${width*0.8}px;
background: radial-gradient(
circle ${circle}px,
${d3.color(divergingScale()(values[0])).hex()},
${d3.color(divergingScale()(values[1])).hex()},
${d3.color(divergingScale()(values[2])).hex()}
)
}
</style>
<div class="radial"></div>
`
}
Insert cell
Insert cell
function divergingScale () {
return d3.scaleLinear()
.domain([0, pivot, max])
.range([c1, c2, c3]) // col1, col2, col3
}
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