Published
Edited
Sep 21, 2021
25 forks
Importers
32 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
name = "New hire"
Insert cell
emoji = "👤"
Insert cell
salary = 70000
Insert cell
Insert cell
data = (await FileAttachment("payroll.csv").csv()).map(autoTypeExcel)
Insert cell
Insert cell
Insert cell
hiring
Insert cell
Insert cell
domain = [new Date(Date.UTC(2021, 0, 1)), new Date(Date.UTC(2022, 0, 1))]
Insert cell
asOf = new Date(Date.UTC(2021, 4, 25))
Insert cell
Insert cell
payroll = new CashFlow(
month => -d3.sum(hiring.map(amortizedSalary(month))),
{label: "Payroll", domain}
)
Insert cell
Insert cell
amortizedSalary = month => ({date, salary}) => (1 - monthFrac(month, date)) * (salary / 12)
Insert cell
monthFrac = (month, date) => date < month ? 0
: date > d3.utcMonth.offset(month, 1) ? 1
: d3.utcDay.count(month, date)
/ d3.utcDay.count(month, d3.utcMonth.offset(month, 1))
Insert cell
Insert cell
newItem = d => ({salary, name, emoji, ...d})
Insert cell
enterItem = g => g.append("g")
.attr("text-anchor", "middle")
.call(g => g.append("text")
.attr("font-size", "2em")
.attr("y", "-0.1em")
.text(d => d.emoji))
.call(g => g.append("text")
.attr("font-size", "10px")
.attr("font-family", "sans-serif")
.attr("y", "-3.75em")
.text(d => d.name))
Insert cell
Insert cell
import {MultidragAxis} with {domain, newItem, enterItem} from "@observablehq/multidrag-axis"
Insert cell
import {CashFlow, autoTypeExcel, dateFormat} from "@observablehq/cash-flow"
Insert cell
import {Table} from "@observablehq/table-validator"
Insert cell
import {CSVText} from "@tophtucker/structured-text-inputs"
Insert cell
import {set} from "@observablehq/synchronized-inputs"
Insert cell
import {toc} from "@observablehq/templates-table-of-instructions"
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