Published
Edited
Feb 24, 2022
3 stars
Insert cell
Insert cell
chart = Plot.dotX(Array.from({ length: 100 }, Math.random)).plot({
x: { domain: [0, 1] }
})
Insert cell
d3
.select(chart)
.select("[aria-label=x-axis]")
.selectAll("text")
.each(function (d) {
// d is the tick's value (in this case, a number)
d3.select(this)
.attr("fill", d < 0.5 ? "red" : d > 0.5 ? "green" : "black")
.attr("font-size", (d * 2) % 1 ? 8 : 15);
})
Insert cell
Insert cell
chart2 = html`<div id=chart2>${Plot.dotX(
Array.from({ length: 100 }, Math.random)
).plot({
x: { domain: [0, 1] }
})}`
Insert cell
html`<style>
#chart2 [aria-label=x-axis] .tick:nth-child(5n+1) text {font-size: 15px}
#chart2 [aria-label=x-axis] .tick:nth-child(n+1):nth-child(-n+5) text {fill: red}
#chart2 [aria-label=x-axis] .tick:nth-child(n+7):nth-child(-n+11) text {fill: green}
`
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