Published unlisted
Edited
Aug 4, 2021
Insert cell
Insert cell
normalizeX()
Insert cell
normalizeX("extent", { x: "value", y: "dimension", z: "dimension" })
Insert cell
normalizeX({ basis: "extent", x: "value", y: "dimension", z: "dimension" })
Insert cell
normalizeX({ x: "value", y: "dimension", z: "dimension" })
Insert cell
// default argument: basis: "first"
function normalizeX(basis = "first", options = {}) {
if (typeof arguments[0] === "object" && !("length" in arguments[0])) {
({ basis, ...options } = { basis: "first", ...options, ...basis });
}
return { basis, options };
}
Insert cell
Insert cell
windowX()
Insert cell
windowX({ k: 21, x: "value", y: "dimension", z: "dimension" })
Insert cell
windowX({ x: "value", y: "dimension", z: "dimension" })
Insert cell
windowX(21, { x: "value", y: "dimension", z: "dimension" })
Insert cell
windowX(21, { x: "value", y: "dimension", z: "dimension", anchor: "end" })
Insert cell
// default arguments: k: 10, anchor: "start"
function windowX(k = 10, options = {}) {
let anchor;
if (typeof arguments[0] === "object" && !("length" in arguments[0])) {
({ k, ...options } = { k: 10, ...options, ...k });
}
({ anchor, ...options } = { anchor: "start", ...options });
return { k, anchor, options };
}
Insert cell
Insert cell
sort()
Insert cell
sort("length", { x: "value", y: "dimension", z: "dimension", anchor: "end" })
Insert cell
sort({ sort: "y", x: "value", y: "dimension", z: "dimension", anchor: "end" })
Insert cell
sort({
sort: "y",
x: "value",
y: "dimension",
z: "dimension",
anchor: "end",
reverse: true
})
Insert cell
// default arguments: sort: undefined, reverse: false
function sort(s, options = {}) {
let reverse;
if (typeof arguments[0] === "object" && !("length" in arguments[0])) {
({ s, ...options } = { s: undefined, ...options, ...sort });
}
({ reverse, ...options } = { reverse: false, ...options });
return { sort: s, reverse, options };
}
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