Published
Edited
Jun 15, 2021
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
md`# Appendix`
Insert cell
runs = FileAttachment("running.csv").csv({ typed: true })
Insert cell
runs.map(r => moment(r.Date, 'DD-MM-YYYY'))
Insert cell
runDates = runs.map(row => ({ ...row, dateM: moment(row.Date, 'DD-MM-YYYY') }))
Insert cell
date1m = nextRun ? moment(nextRunDate, 'YYYY-MM-DD') : moment()
Insert cell
date2m = nextRun
? moment(nextRunDate, 'YYYY-MM-DD').subtract(33, 'days')
: moment().subtract(33, 'days')
Insert cell
date2w = nextRun
? moment(nextRunDate, 'YYYY-MM-DD').subtract(6, 'days')
: moment().subtract(6, 'days')
Insert cell
moment
Insert cell
monthlyRuns = runDates.filter(
run => (run.dateM < date2w) & (run.dateM >= date2m)
)
Insert cell
initialValue = 0

Insert cell
monthlySum = monthlyRuns.reduce(
(accumulator, currentValue) => accumulator + currentValue.Distance,
initialValue
)
Insert cell
monthyAverage = Math.round((monthlySum / 4) * 10) / 10
Insert cell
weeklySum = weeklyRuns.reduce(
(accumulator, currentValue) => accumulator + currentValue.Distance,
initialValue
) + gain
Insert cell
weeklyRuns = runDates.filter(
run => (run.dateM <= date1m) & (run.dateM >= date2w)
)
Insert cell
acuteChronic = Math.round((weeklySum / monthyAverage) * 100) / 100
Insert cell
date1m.format("DD-MM-YYYY")
Insert cell
date2m.format("DD-MM-YYYY")
Insert cell
date2w.format("DD-MM-YYYY")
Insert cell
nextRun = gain > 0
Insert cell
moment = require('moment')
Insert cell
d3 = require("d3@5")
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