Public
Edited
Jan 8, 2023
Insert cell
Insert cell
Insert cell
Insert cell
// Most common base stat totals
sortedCounts = _.sortBy(_.groupBy(statPokedex, baseStatTotal), count => -count.length)
Insert cell
Insert cell
// mons that lose or keep same stats when evolving
pokedexList.filter(mon => mon.prevo && baseStatTotal(getPrevo(mon)) >= baseStatTotal(mon))
Insert cell
// list of evos by ordered by total stat increases
_.sortBy(
pokedexList.filter((mon) => mon.prevo),
(mon) => baseStatTotal(mon) - baseStatTotal(getPrevo(mon))
).map((mon) => mon.name)
Insert cell
// evos that lose stats upon evolving
["hp", "atk", "def", "spa", "spd", "spe"].map((stat) =>
pokedexList.filter(
(mon) => mon.prevo && getPrevo(mon).baseStats[stat] > mon.baseStats[stat]
).map(mon => mon.name)
)
Insert cell
// evos that keep stats same upon evolving
["hp", "atk", "def", "spa", "spd", "spe"].map((stat) =>
pokedexList.filter(
(mon) => mon.prevo && getPrevo(mon).baseStats[stat] === mon.baseStats[stat]
).map(mon => mon.name)
)
Insert cell
// evos ranked by stat gain per stat
statNames.map(stat => {
return _.sortBy(pokedexList.filter(mon => mon.prevo), mon => -(mon.baseStats[stat] - getPrevo(mon).baseStats[stat])).map(mon => mon.name)
})
Insert cell
Insert cell
// evos that have an even stat gain across all stats
equalStatGains = statPokedex.filter(mon => {
if (!mon.prevo) return false
const diff = statDiff(mon, getPokemon(mon.prevo))
return _.uniq(Object.values(diff)).length === 1
}).map(mon => mon.name)
Insert cell
Insert cell
viewof tieCutoff = Inputs.range([1, 6], { value: 2, step: 1, label: "Cutoff for tied stats"})
Insert cell
Insert cell
Insert cell
typeStatsCount = {
const combos = [];
for (const type of types) {
for (const stat of statNames) {
const bestCount = statPokedex.filter((mon) => {
return mon.types.includes(type) && bestStats(mon).includes(stat);
}).length;
const worstCount = statPokedex.filter((mon) => {
return mon.types.includes(type) && worstStats(mon).includes(stat);
}).length;
combos.push({
type,
stat,
bestCount,
worstCount
});
}
}
return combos
}
Insert cell
function bestStats(pokemon) {
const maxStat = Math.max(...Object.values(pokemon.baseStats))
const bestStats = statNames.filter(stat => pokemon.baseStats[stat] === maxStat)
// Don't count mons with even stats
return bestStats.length > tieCutoff ? [] : bestStats
}
Insert cell
function worstStats(pokemon) {
const minStat = Math.min(...Object.values(pokemon.baseStats))
const worstStats = statNames.filter(stat => pokemon.baseStats[stat] === minStat)
// Don't count mons with even stats
return worstStats.length > tieCutoff ? [] : worstStats
}
Insert cell
statNames = ['hp', 'atk', 'def', 'spa', 'spd', 'spe']
Insert cell
statPokedex = pokedexList.filter(mon => {
if (mon.baseSpecies) {
return !_.isEqual(mon.baseStats, getPokemon(mon.baseSpecies).baseStats)
}
return true
}
)
Insert cell
function statDiff(mon1, mon2) {
return _.mapValues(mon1.baseStats, (value, stat) => value - mon2.baseStats[stat])
}
Insert cell
import { pokedexList, getPokemon, getPrevo, pokemonWithEvolutionChain, types, baseStatTotal } from "@tesseralis/pokemon-dataviz"
Insert cell
import { vl } from "@vega/vega-lite-api-v5"
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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