Public
Edited
Feb 1, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
typical@1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
log.slice(-20)
Insert cell
x = d3.scaleLinear()
.domain(d3.extent(data, d => scratchScore(d)).nice()
.range([margin.left, width - margin.right])
Insert cell
y = d3
.scaleLinear()
.domain(d3.extent(data, (d) => podiumScore(d)))
.nice()
.range([height - margin.bottom, margin.top])
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x))
Insert cell
yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
Insert cell
margin = ({top: 25, right: 20, bottom: 35, left: 40})
Insert cell
scratchScore = (games) => {
const top3 = sortedGames(games).slice(-3);
const scratch = top3.reduce((a, n) => a + parseInt(n, 10), 0);
return scratch;
}
Insert cell
adjustment = (games) => {
const average =
sortedGames(games).reduce((a, n) => a + parseInt(n, 10), 0) / 5;
const adj = Math.round(
(Math.max(adjustmentMax, average) - average) * (adjustmentPct / 100)
);
return adj;
}
Insert cell
penalty = (games) => {
const sorted = sortedGames(games);
const topAvg = sorted.slice(-2).reduce((a, n) => a + parseInt(n, 10), 0) / 2;
const bottomAvg =
sorted.slice(0, 2).reduce((a, n) => a + parseInt(n, 10), 0) / 2;
return Math.floor(topAvg - bottomAvg);
}
Insert cell
podiumScore = (games) => {
return scratchScore(games) + adjustment(games) - penalty(games);
}
Insert cell
sortedGames = (games) =>
Object.values(games)
.map((v) => parseInt(v, 10))
.sort((a, b) => (b < a ? 1 : -1))
Insert cell
import { log } from "@sorig/console-log-without-leaving-your-notebook"
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
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