Public
Edited
Sep 29, 2023
Insert cell
Insert cell
inputs = ({
"19apr2021": [
{ z1: [7, 29], z2: [47, 9], z3: [12, 49] },
{ z1: [2, 53], z2: [34, 19], z3: [0, 12] },
{ z1: [1, 36], z2: [50, 5], z3: [32, 27], z4: [0, 12] },
{ z1: [2, 12], z2: [33, 54], z3: [0, 15] }
],
"17may2021": [
{ z1: [2, 34], z2: [32, 16], z3: [29, 11], z4: [1, 35] },
{ z1: [5, 8], z2: [34, 16] },
{ z1: [4, 43], z2: [48, 40], z3: [20, 36] },
{ z1: [1, 38], z2: [60, 55], z3: [0, 23] },
{ z1: [8, 43], z2: [27, 29] }
]
})
Insert cell
result
X
zone
Y
minutes
Color
zone
Size
Facet X
Facet Y
week
Mark
bar
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
function sumWorkouts(workouts) {
const result = {};
for (const workout of workouts)
for (const [key, [minutes, seconds]] of Object.entries(workout)) {
result[key] ||= 0;
result[key] += minutes + seconds/60;
}
return Object.entries(result).map(([zone, minutes]) => ({zone, minutes}));
}
Insert cell
result = Object.entries(inputs)
.map(([week, workouts]) =>
sumWorkouts(workouts).map((zones) => ({ ...zones, week }))
)
.reduce((a, b) => [...a, ...b], [])
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