Published
Edited
Feb 11, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Object.keys(divisionAnalytics).map(division => ({
division,
gameplay: divisionAnalytics[division].averageGameplay
})).sort((a, b) => b.gameplay - a.gameplay)
Insert cell
divisionAnalytics = {
const byDivision = {}
for (let [division, games] of divisionGamesMap) {
byDivision[division] = gameAnalytics(games)
}
return byDivision
}
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const startYear = 2017
return vl.markCircle({ size: 200, opacity: 1, stroke: 2 })
.data(teamSeasons.filter(s => s.Year >= startYear))
.encode(
vl.y().average("Fight").axis({ title: `Average Fight (${startYear} - 2019)` }).scale({ }),
vl.color().fieldN("Team").scale({ domain: teams.map(d => d.id), range: teams.map(d => d.primaryColor) }).legend(null),
vl.x().average("Heartbreak").axis({ title: `Average Heartbreak (${startYear} - 2019)` }).scale({ }),
vl.tooltip(['Team'])
).config(defaultChartConfig)
.width(600)
.render()
}
Insert cell
Insert cell
// d3.rollup(games.filter(d => d.Playoffs), v => d3.mean(v, d => d.Gameplay), d => d.Year)
Insert cell
{
const bestGames = games.filter(g => g.Year >= 2013 && (g.Playoffs)).sort((a, b) => d3.descending(a.Gameplay, b.Gameplay)).slice(0, 30)
const gamesInfo = bestGames.map(g => {
const gameText = g.Playoffs ? (g.winningTeamMeta.conference !== g.losingTeamMeta.conference ? 'Super Bowl' : 'Playoffs') : null
const s = `${g.winningTeamMeta.name} ${g['Winning Score']} - ${g['Losing Score']} ${g.losingTeamMeta.name} (${g.Year}${gameText ? ' - ' + gameText : ''})`
return s
})
return md`
### Best Playoff Games
1. ${gamesInfo.join('\n\n1. ')}
`
}
Insert cell
Insert cell
Insert cell
Insert cell
d3.extent(teamSeasons, d => d['Total Excitement'])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@5", "d3-array@2")
Insert cell
import { vl } from "@vega/vega-lite-api"
Insert cell
Insert cell
lightChartConfig = ({
...defaultChartConfig,
view: { fill: 'white', stroke: 'white' }
})
Insert cell
import {select} from "@robert-moore/inputs"
Insert cell
import {checkbox} from "@jashkenas/inputs"
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