Published
Edited
Aug 6, 2020
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
q = 5
Insert cell
sessions = [1, 2, 3, 4, 5]
Insert cell
secondInterval = isNaN(userSecondInterval) ? 6 : userSecondInterval
Insert cell
data = simSessions(topicObj, sessions, 5, secondInterval)
Insert cell
displayData = data.map(s => ({
session: s.session,
EF: s.EF,
interval: s.I,
day: s.day
}))
Insert cell
simSessions = (topicObj, sessions, q, secondInterval) => {
let lastSession = { session: 0, EF: 2.5, I: 0, day: 0 };
console.log(lastSession);
let day;
let sessionObjs = sessions.map((s, i) => {
console.log('iteration:', i, lastSession);
day = lastSession.day;
lastSession = getInterval(lastSession, q, secondInterval);
lastSession.day = lastSession.I + day;
return lastSession;
});
return sessionObjs;
}
Insert cell
topicObj = ({ name: 'verb_easy', sessions: [{ session: 0, EF: 2.5, I: 0 }] })
Insert cell
Insert cell
reducer = (accumulator, currentValue) => accumulator + currentValue
Insert cell
import { Scrubber } from "@mbostock/scrubber"
Insert cell
x = d3
.scaleLinear()
.domain(d3.extent(data, d => d.I))
.nice()
.range([margin.left, width - margin.right])
Insert cell
y = d3
.scaleLinear()
.domain(d3.extent(data, d => d.session))
.nice()
.range([height - margin.bottom, margin.top])
Insert cell
xAxis = g =>
g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).ticks(width / 80))
.call(g => g.select(".domain").remove())
.call(g =>
g
.append("text")
.attr("x", width)
.attr("y", margin.bottom - 4)
.attr("fill", "currentColor")
.attr("text-anchor", "end")
.text(data.I)
)
.call(g =>
g
.append("text")
.attr("x", width - margin.right)
.attr("y", -6)
.attr("fill", "#000")
.attr("text-anchor", "end")
.attr("font-weight", "bold")
.text("Inter repetition interval (I) →")
)
Insert cell
yAxis = g =>
g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
.call(g =>
g
.append("text")
.attr("x", -margin.left)
.attr("y", 10)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.text(data.session)
)
.call(g =>
g
.append("text")
.attr("x", 20)
.attr("y", margin.top - 10)
.attr("fill", "#000")
.attr("text-anchor", "end")
.attr("font-weight", "bold")
.text("Sessions")
)
Insert cell
margin = ({ top: 25, right: 20, bottom: 35, left: 40 })
Insert cell
height = 600
Insert cell
import { number } from "@jashkenas/inputs"
Insert cell
import { table } from "@tmcw/tables/2"
Insert cell
d3 = require("d3@5")
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