Public
Edited
Nov 27, 2023
Insert cell
Insert cell
Insert cell
games = FileAttachment("playstation2_games.csv").csv()
Insert cell
Insert cell
gamesv2 = {
let new_games = []
games.forEach(function(d, i){
d['date_string'] = d['First released'].replace(/[a-zA-Z]/g, '');
d['date'] = new Date(d['date_string']);
d['year'] = d['First released'].split('-')[0] * 1;
new_games.push(d);
})

return new_games
}
Insert cell
Insert cell
Inputs.table(gamesv2)
Insert cell
gpy=d3.rollup(gamesv2, v => d3.count(v, d => d['id']), d => d['year'])
Insert cell
arraygpy = [...gpy]
.filter(item => !isNaN(item[0]) && item[0] !== 0) // Filtrar los valores no deseados
.map(item => ({ Año: item[0], Total: item[1] }))
.sort((a, b) => d3.descending(a.Total, b.Total));
Insert cell
Plot.plot({
marginLeft: 60,
x: {inset: 1},
y: {label: null},
marks: [
Plot.dot(arraygpy, {x: "Año", y: "Total"})
]
})
Insert cell
Insert cell
gpd=d3.rollup(gamesv2, v => d3.count(v, d => d['id']), d => d['Developer'])
Insert cell
arraygpd = [...gpd].map(function (item) {
return { Developer: item[0], Total:item[1] }
}).sort((a, b) => d3.descending(a.total, b.total));
Insert cell
top10Dev = arraygpd.slice(0, 10);
Insert cell
Plot.plot({
marks: [
Plot.barX(top10Dev, {
x: "Total",
y: "Developer",
sort: { y: "x", reverse: true },
fill: "pink"
}),
Plot.ruleX([0])
]
})
Insert cell
Insert cell
gped = d3.rollup(
gamesv2,
v => ({
asociacion: d3.every(v, d => d.Developer === d.Publisher) ? 1 : 0
}),
d => d.Title
);

Insert cell
arraygped = [...gped].map(([title, { total, asociacion }]) => ({
Title: title,
Asociacion: asociacion
}));

Insert cell
asociacionSum = arraygped.reduce((acc, item) => {
if (item.Asociacion === 1) {
acc.asociacion1 += 1;
} else {
acc.asociacion0 += 1;
}
return acc;
}, { asociacion1: 0, asociacion0: 0 });
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more