catalog = FileAttachment("data/final_results/catalog.json").json()
movies = catalog.movies || []
// Helper: Count occurrences
function countBy(array, key) {
const counts = {};
for (const item of array) {
const value = item[key];
if (value) {
counts[value] = (counts[value] || 0) + 1;
}
}
return Object.entries(counts).sort((a, b) => b[1] - a[1]);
}
// Helper: Count array values (for genres)
function countArrayValues(array, key) {
const counts = {};
for (const item of array) {
const values = item[key] || [];
for (const value of values) {
if (value) {
counts[value] = (counts[value] || 0) + 1;
}
}
}
return Object.entries(counts).sort((a, b) => b[1] - a[1]);
}
// Stats
totalCount = movies.length
enrichedCount = movies.filter(m => m.enriched).length
withPoster = movies.filter(m => m.poster && m.poster !== "https://i.imgur.com/Ngnm5v6.png").length
withDirector = movies.filter(m => m.director).length
withYear = movies.filter(m => m.year).lengthEstadísticas
📊 Estadísticas del Catálogo
Visualizaciones del catálogo de películas de la Biblioteca Vasconcelos.
📈 Resumen General
📁 Películas por Categoría
🎬 Géneros Más Frecuentes
📅 Distribución por Década
🌍 Películas por País (Top 15)
🎬 Directores Más Frecuentes (Top 15)
⭐ Distribución de Ratings IMDb
```{ojs}
//| echo: false
ratingData = movies
.filter(m => m.imdb_rating && m.imdb_rating !== "N/A")
.map(m => ({
rating: parseFloat(m.imdb_rating),
title: m.title
}))
.filter(m => !isNaN(m.rating))
// Bin ratings
ratingBins = {};
for (const {rating} of ratingData) {
const bin = Math.floor(rating);
ratingBins[bin] = (ratingBins[bin] || 0) + 1;
}
ratingBinData = Object.entries(ratingBins)
.map(([rating, count]) => ({rating: parseInt(rating), count}))
.sort((a, b) => a.rating - b.rating)
Plot.plot({
height: 300,
x: {label: "Rating IMDb", tickFormat: d => d + "-" + (d+1)},
y: {label: "Número de películas", grid: true},
marks: [
Plot.barY(ratingBinData, {
x: d => d.rating,
y: d => d.count,
fill: "#fbbf24",
tip: true
}),
Plot.ruleY([0])
]
})
```
ImportantOJS Syntax Error (line 228, column 1)Unexpected token
Generado el desde datos de OMDB API