Published
Edited
Apr 23, 2021
1 star
Insert cell
Insert cell
caseStripes = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
const stripeWidth = x(1) - x(0) + 1;

svg
.selectAll("rect")
.data(data)
.enter()
.append("rect")
.attr("height", height)
.attr("width", stripeWidth)
.attr("fill", (d) => (isNaN(d) ? "#f3efecff" : color(d)))
.attr("x", (d, i) => x(i))
.attr("y", 0);

return svg.node();
}
Insert cell
x = d3.scaleLinear().domain([0, data.length]).range([0, width])
Insert cell
x(1) - x(0)
Insert cell
color = d3
.scaleDiverging()
.domain([d3.max(data), 0, d3.min(data)])
.interpolator(d3.interpolateRdBu)
Insert cell
Insert cell
height = 400
Insert cell
data = {
let retval = new Array();
let index = 0;
let sum = 0;

firstDerivative.forEach((element) => {
index++;
sum += element;
if (index == 5) {
retval.push(sum);
index = 0;
sum = 0;
}
});

if (index > 0) retval.push(sum);

return retval;
// return firstDerivative.filter((d, i) => i >= firstDerivative.length - 220);
// return firstDerivative;
}
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