Public
Edited
Jan 6, 2023
Insert cell
Insert cell
Insert cell
apiLogData = (await FileAttachment("apiLogData.json").json()) // Load & parse the JSON file
.map((d) => ({ ...d, timestamp: new Date(d.timestamp) })) // Convert string timestamps to Date objects
Insert cell
Inputs.table(apiLogData)
Insert cell
Insert cell
Insert cell
Plot.dot(apiLogData, {
x: 'timestamp',
y: 'duration',
fill: 'path',
fillOpacity: 0.75,
title: (d) => [d.path, `${d.duration} ms`, `status ${d.status_code}`].join("\n")
}).plot({
width,
height: width * 0.4,
marginLeft: 50
})
Insert cell
Insert cell
Insert cell
viewof favColors = Inputs.checkbox(
["red", "orange", "yellow", "green", "blue", "purple"],
{ label: "Colors I like:" }
)
Insert cell
Insert cell
favColors
Insert cell
Insert cell
favColors.map((s) => s.toUpperCase())
Insert cell
`I like the colors ${favColors.join(", ")}`
Insert cell
Insert cell
viewof selectedCodes = Inputs.checkbox(statusCodes, { value: statusCodes })
Insert cell
selectedCodes
Insert cell
statusCodes = Array.from(new Set(apiLogData.map((d) => d.status_code))).sort()
Insert cell
Insert cell
Insert cell
Insert cell
// TODO copy your plot code here
// then update it to only plot responses with the selected status codes
Insert cell
Insert cell
Insert cell
viewof pathSearch = Inputs.search(
[] // TODO replace this
)
Insert cell
Inputs.table(pathSearch) // Displays the data found by pathSearch, for reference
Insert cell
// TODO paste & update your plot here to connect it to the pathSearch filtered data array
Insert cell
Insert cell
Insert cell
viewof finishedSelectedCodes = Inputs.checkbox(statusCodes, {
value: statusCodes
})
Insert cell
viewof finishedPathSearch = Inputs.search(apiLogData)
Insert cell
// One possible solution; yours may differ!
finishedResponses = Plot.dot(
finishedPathSearch.filter((d) =>
finishedSelectedCodes.includes(d.status_code)
),
{
x: "timestamp",
y: "duration",
fill: "path",
fillOpacity: 0.5,
title: (d) =>
[d.path, `${d.duration} ms`, `status ${d.status_code}`].join("\n")
}
).plot({
width,
marginLeft: 50
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more