Public
Edited
Jan 6, 2023
1 fork
4 stars
Also listed in…
Grid
Insert cell
Insert cell
Insert cell
Insert cell
series = d3.range(settings.wide + settings.tall)
Insert cell
grid = (
({wide, tall, dash, showH, showV, showUps, showDowns}) => // from Settings
(series) =>
R.map(scale(width / wide))(
R.unnest(
[
show(R.map(v(tall))(d3.range(wide + 1)))(showH),
show(R.map(h(wide))(d3.range(tall + 1)))(showV),
show(R.map(line(up({wide, tall})))(series))(showUps),
show(R.map(line(down({wide, tall})))(series))(showDowns),
]
)
)
)
(settings)(series)
Insert cell
up = ({wide, tall}) => ({
top: {
x: i => [i, wide][+(i > wide - 1)],
y: i => [0,i - wide][+(i > wide)]
},
bot: {
x: i => [0,i - tall][+(i > tall)],
y: i => [i, tall][+(i > tall)]
}
})
Insert cell
down = ({wide, tall}) => ({
top: {
x: i => [0,i-tall][+(i > tall)],
y: i => [tall-i,0][+(i > tall)]
},
bot: {
x: i => [i,wide][+(i > wide)],
y: i => [tall,tall-i+wide][+(i > wide)]
}
})
Insert cell
dots = ({wide, tall, step = width / wide}) =>
R.chain
(scale(step)) // scale all entries
(
R.map // of rows x columns matrix of points
(rows(d3.range(tall + 1)))
(d3.range(wide + 1))
)
Insert cell
rows = (cols) => (row) => R.map(point(row))(cols)
Insert cell
point = row => col => [row, col]
Insert cell
scale = (s) => R.map(resize(s)); // each square’s size
Insert cell
resize = (step) => (p) => R.map(k => k * step)(p); // resize all coords
Insert cell
v = (tall) => i => [[i, 0], [i, tall]]; // vertical line at x = i
Insert cell
h = (wide) => i => [[0, i], [wide, i]]; // horizontal line at y = i
Insert cell
line = ({top, bot}) => (i) => [coord(i)(top), coord(i)(bot)]
Insert cell
coord = (i) => ({x, y}) => [x(i), y(i)]
Insert cell
show = (list) => (visibility) => [[], list][+visibility]
Insert cell
R = require("ramda")
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