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

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