Published
Edited
Aug 22, 2022
2 forks
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
allDays = flatUserArray.map((d) => d.days)
Insert cell
color = d3
.scaleLinear()
.domain([25, 13, 0])
.range(["#F081A1", "#E5ADFF", "#3AC9E9"])
.clamp(true)
Insert cell
expScale = d3.scalePow().exponent(Math.E).domain([0, 25])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
flatUserArray = Array.from(userDataByDays).map((value, key) => {
return {
id: value[0],
days: Array.from(value[1]).map((d) => {
let glucoseValues = d[1].map((e) => {
return e.value;
});
return {
day: d[0],
values: d[1],
deviation: d3.deviation(glucoseValues)
};
})
};
})
Insert cell
allUserDeviation = flatUserArray
.map((d) => {
return d.days.map((e) => {
return e.deviation;
});
})
.flat()
Insert cell
ids = Array.from(userDataByDays.keys())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// normal_curve = {
// const points = [];
// for (let value of d3.range(...x.domain(), bin_width / 10)) {
// points.push([
// value,
// dnorm(value, sample_mean, sample_sd) * bin_width * sample_size
// ]);
// }
// return points;
// }
Insert cell
sample_sd = ssd(sample)
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