Published
Edited
Feb 17, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// this is the function which I would love ideas to improve.
function concatenateScales(scale1, scale2) {
const scale = value => {
if (value < scale1.domain()[1]) {
return scale1(value);
} else if (value >= scale2.domain()[0]) {
return scale2(value);
} else {
throw new Error(`invalid input: ${value}`);
}
};
// example implementation of scale.domain and scale.range getters
scale.domain = () => [scale1.domain()[0], scale2.domain()[1]];
scale.range = () => [scale1.range()[0], scale2.domain()[1]];
return scale;
}
Insert cell
Insert cell
Insert cell
Insert cell
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