Public
Edited
Oct 17, 2022
Importers
1 star
Also listed in…
Coronavirus
Insert cell
Insert cell
Insert cell
data = aranetData(await FileAttachment("SampleAranetData.csv").csv())
Insert cell
Insert cell
co2Chart(data, {
timeDomain: [utc(2022, 6, 4), utc(2022, 6, 5)],
thresholds: [450, 800, 1000, 2500, 2500],
ticks: [0, 450, 800, 1000, 2000]
})
Insert cell
Insert cell
milestones = [
[utc(2022, 6, 4, 14, 45), 'Car to camp', '2 people'],
[utc(2022, 6, 4, 16, 20), 'Cabin', '2 people, windows open'],
[utc(2022, 6, 4, 18, 0), 'Dining hall', 'Moving both indoors and outdoors'],
[utc(2022, 6, 4, 19, 10), 'Cabin', '2 people'],
[utc(2022, 6, 4, 19, 30), 'Dance in C♯', 'In pocket'],
[utc(2022, 6, 4, 23, 0), 'Party in C♯m'],
[utc(2022, 6, 5, 2, 0)]
]
Insert cell
co2MilestonesChart(data, milestones, { timeDomain: [utc(2022, 6, 4, 14, 45), utc(2022, 6, 5, 2, 0)] })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
co2Chart(data, {
timeDomain: [utc(2022, 6, 4), utc(2022, 6, 5)],
thresholds: [450, 800, 1000, 2500, 2500],
ticks: [0, 450, 800, 1000, 2000]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
utc(2022, 7, 2)
Insert cell
Insert cell
Insert cell
colorGradient = (data, thresholds, id, vertical = false) => {
if (thresholds.length < 5) throw 'Must have 5 threshold levels'
const s = d3.scaleLinear(
d3.extent(data, (d) => d.co2),
[0, 100]
)
return () => htl.svg.fragment`<defs>
<linearGradient id=${id} gradientTransform=${vertical ? 'rotate(-90 0.5 0.5)' : null}>
<stop stop-color=${d3.lch(80, 65, 150)} offset=0 />
<stop stop-color=${d3.lch(80, 65, 150)} offset=${s(thresholds[0] - 1)}% />
<stop stop-color=${d3.lch(70, 65, 150)} offset=${s(thresholds[0])}% />
<stop stop-color=${d3.lch(70, 65, 150)} offset=${s(thresholds[1] - 1)}% />
<stop stop-color=${d3.lch(80, 80, 90)} offset=${s(thresholds[1])}% />
<stop stop-color=${d3.lch(80, 80, 90)} offset=${s(thresholds[2] - 1)}% />
<stop stop-color=${d3.lch(60, 80, 40)} offset=${s(thresholds[2])}% />
<stop stop-color=${d3.lch(60, 80, 40)} offset=${s(thresholds[3] - 1)}% />
<stop stop-color=${d3.lch(60, 80, 40, 0.2)} offset=${s(thresholds[3])}% />
<stop stop-color=${d3.lch(60, 80, 40, 0)} offset=${s(thresholds[4])}% />
<stop stop-color=${d3.lch(60, 80, 40, 0)} offset=100% />
</linearGradient>
</defs>`
}
Insert cell
milestonesToPeriods = ms => ms.map((d, i, arr) => ({
start: d[0],
end: arr.length > i + 1 ? arr[i+1][0] : null,
event: d[1],
description: d[2],
}))
Insert cell
aranetImageUrl = FileAttachment("aranet4.jpg").url()
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