Public
Edited
Mar 12
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scaleThresholdDomain = {
let scaleThresholdDomain;
console.log("");
if (true) {
//if (!simetricExtent) {
let stepRight = (_extent[1] - threshold) / Math.floor(steps / 2);
let thresholdsRight = d3.range(threshold, _extent[1], stepRight);
console.log(1);
console.log(_extent);
let stepLeft = Math.abs(threshold - _extent[0]) / Math.floor(steps / 2);
let thresholdsLeft = d3.range(
_extent[0] + stepLeft,
threshold + stepLeft,
stepLeft
);
scaleThresholdDomain = _.uniq([...thresholdsLeft, ...thresholdsRight]);
console.log(thresholdsLeft, thresholdsRight);
} else {
// we don't need this
console.log(2);
let step = Math.abs(_extent[1] - _extent[0]) / steps;
let thresholds = d3.range(_extent[0], _extent[1] + step, step);
// why dropping first and last threshold?
// Threshold scales assign the first colour to values below the first threshold, and last colour to values
// above the last threshold, but we want our first/last colour to represent our extent values, so we remove
// our extent values from the thresholds
let innerTresholds = _.drop(_.dropRight(thresholds));
scaleThresholdDomain = innerTresholds;
console.log(scaleThresholdDomain);
}
return scaleThresholdDomain;
}
Insert cell
Insert cell
Insert cell
Insert cell
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