Public
Edited
Aug 9, 2023
Fork of Simple D3
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rangeDomainValue = [-24, 100]
Insert cell
data = [-1, 0, 0.01, 0.1, 0.45, 0.5, 0.51, 0.7, 0.75, 0.79, 0.799, 0.8, 0.9, 1, 20, 25, 25.1, 45, 49.9, 50, 50.01, 50.1, 74.9, 75, 75.1, 88, 99, 100]
Insert cell
Insert cell
dataPP = data.map(e => Math.round(e))
Insert cell
Insert cell
Insert cell
quantize(-1) // expected: #374151
Insert cell
quantize(0) // expected: #374151
Insert cell
quantize(0.9)
Insert cell
quantize(1) // expected: #55c56f
Insert cell
quantize(10) // expected: #55c56f
Insert cell
quantize(25) // expected "#55c56f"
Insert cell
quantize(45)
Insert cell
quantize(50)
Insert cell
quantize = d3.scaleQuantize()
.domain(rangeDomainValue) // extreme values to a scaleQuantize’s domain
.range([colorNR, colorCB, colorCM, colorCS, colorCA])
Insert cell
Insert cell
tscale = d3.scaleThreshold([0, 26, 51, 76], [colorNR, colorCB, colorCM, colorCS, colorCA]);
Insert cell
chart([undefined, -50, -20, -1, 0, 25, 26, 50, 51, 75, 76, 80, 100], tscale)
Insert cell
tscale(36)
Insert cell
dataPP
Insert cell
Insert cell
tmscale = d3.scaleThreshold([0, 26, 51, 76], [colorNR, 'none', colorCM, colorCS, colorCA]);
Insert cell
chart([undefined, -50, -20, -1, 0, 25, 26, 50, 51, 75, 76, 80, 100], tmscale)
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