Public
Edited
May 7
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
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.dot(furnace_air_data, {"x": "date", "y": "result"}) // Update this mark to create a scatterplot
],
})
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
y: {
domain: [0, 3000]
},
marks: [
// This draws a line at the respirator max protection limit. You don't need to change this.
Plot.ruleY([2500], {stroke: "red", strokeWidth: 3}),

Plot.dot(furnace_air_data, {"x": "date", "y": "result"}) // Update this mark to create a scatterplot
]
})
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
mappedResults = {
function formatRow(row) {
let afterEnclosed = new Date(row.date) >= new Date(2013, 0, 1) // Update ??? to compare the row's date to the date when the factory was enclosed

// Update the next line to compare the row's result to the limit of 2500
// exceedsProtection should be true if the row's result is greater than 2500
let exceedsProtection = row.result > 2500;


// If you've done everything correctly above, you don't need to do anything else!
return {
...row,
exceeds_protection: exceedsProtection,
after_enclosed: afterEnclosed,
}
}

return furnace_air_data.map(formatRow);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
enclosureDates = [
{date: new Date(2013, 0, 1)},
{date: new Date(2020, 5, 1)}
]
Insert cell
Insert cell
areaMark = Plot.area(enclosureDates, {
x1: "date",
y1: 0,
y2: 85000,
fill: "lightblue",
opacity: 0.5
});
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
readingsBefore = correctResults.filter(row => !row.after_enclosed)
Insert cell
readingsAfter = correctResults.filter(row => row.after_enclosed) // Update this to return the inverse of the above example
Insert cell
Insert cell
avgs = {
const sum = (x, y) => x + y;

return {
before: readingsBefore.map(x => x.result).reduce(sum) / readingsBefore.length,
after: readingsAfter.map(x => x.result).reduce(sum) / readingsAfter.length
}
}
Insert cell
Insert cell
function pctIncrease(averageBefore, averageAfter) {
return ((averageAfter - averageBefore) / averageBefore);
}
Insert cell
Insert cell
You got: **${fmtPct(pctIncrease(avgs.before, avgs.after))}**
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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