Public
Edited
Aug 24, 2023
Insert cell
Insert cell
viewof file = Inputs.file({label: "Data"})
Insert cell
data = file.json()
Insert cell
Plot.plot({
marks: [Plot.tickX(timestamps, { x: "timestamp" })]
})
Insert cell
timestamps = data.map((e) => ({ timestamp: parseFloat(e.timestamp) }))
Insert cell
reduction = timestamps.reduce((acc, cur) => {
if (acc[cur.timestamp] == undefined) {
acc[cur.timestamp] = 0;
}
acc[cur.timestamp] += 1;
return acc;
}, {})
Insert cell
amounts = {
return Object.values(reduction);
}
Insert cell
times = {
return Object.keys(reduction);
}
Insert cell
rdata = Array(times.length)
.fill(0)
.map((e, i) => ({ time: parseFloat(times[i]), amount: amounts[i] }))
Insert cell
rdata.filter((e) => e.amount > 4)
Insert cell
Plot.plot({
marks: [Plot.dot(rdata, { y: "amount", x: "time" })]
})
Insert cell
extrainfo = timestamps.reduce((acc, cur, i) => {
if (acc[cur.timestamp] == undefined) {
acc[cur.timestamp] = { count: 0, inds: [] };
}
acc[cur.timestamp].count += 1;
acc[cur.timestamp].inds.push(i);
return acc;
}, {})
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