Published
Edited
Apr 29, 2022
1 fork
8 stars
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
Insert cell
Insert cell
annotationElevation = 100
Insert cell
projectedEnd = new Date(+new Date() + estimatedTimeLeftDays * 24 * 60 * 60 * 1000)
Insert cell
lastBurndownDay = burndownData.slice(-1)[0]
Insert cell
burndownData = d3
.utcDays(new Date(2022, 3, 18), new Date(), 1)
.map((date) => ({
date,
shipped: data
.filter((d) => d["Shipped?"] === "Yes")
.filter((d) => d["Date Shipped"] <= date).length
}))
.map((d) => ({ ...d, remaining: data.length - d.shipped }))
.reduce((acc, d) => {
if (acc.length === 0) {
return [{...d, incrShipped: d.shipped}];
} else {
return [...acc, {...d, incrShipped: d.shipped - acc.slice(-1)[0].shipped}];
}
}, [])
Insert cell
estimatedTimeLeftDays = {
let pace = d3.mean(burndownData, d => d.incrShipped);
return burndownData.slice(-1)[0].remaining / pace;
}
Insert cell
Insert cell
newestProcessingOrder = aq.from(data)
.filter(d => d['Status'] === "Processing")
.orderby(aq.desc("Order ID"))
.slice(0, 1)
.objects()[0]
Insert cell
newestShippedOrder = aq.from(data)
.filter(d => d['Status'] === "Shipped")
.orderby(aq.desc("Order ID"))
.slice(0, 1)
.objects()[0]
Insert cell
Insert cell
data = aq
.from(raw)
// remove null rows
// .filter(d => d["Shipped?"])
.objects()
.map((d) => ({ ...d, "Date Shipped": new Date(d["Date Shipped"]) }))
Insert cell
raw = {
refresh
// use stored data or live data?
if (useArchived) { return FileAttachment("playdate_tracking_2022_04_28.csv").csv({typed:true})}
else { return d3.csv(getCsvUrl(playdateDataURL), d3.autoType) }
}
Insert cell
playdateDataURL = "https://docs.google.com/spreadsheets/d/1ioAvAZJgs8KRrZIGVxJAe9JgtfyJ_OwUqrMp5qV8wfg/edit#gid=475965732"
Insert cell
// from https://observablehq.com/@observablehq/google-sheets-starter
// Converts a Google Sheets website URL to its CSV URL. You can also go to “File → Publish to web”, select the “Comma-separated values (.csv)” type, select the sheet with your data, and use that CSV URL directly with `d3.csv` above. If you need data to update faster, try the Google Sheets API: https://stackoverflow.com/questions/30082277/accessing-a-new-style-public-google-sheet-as-json/44479726#44479726

getCsvUrl = url => {
url = new URL(url);
const id = url.pathname.split("/")[3]
const gid = new URLSearchParams(url.hash.slice(1)).get("gid") || 0;
return `https://docs.google.com/spreadsheets/d/${id}/export?format=csv&gid=${gid}`
}
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