EstadisticasComponent at /controlmedios/estadisticas. It renders three bar charts drawn from the same WordPress dataset used by the rest of the application, giving supervisors a quick read on coverage distribution across outlets, programs, and topics.
Route structure
| Route | View |
|---|---|
/controlmedios/estadisticas | All categories, all media (default) |
/controlmedios/estadisticas/c/:cat | Filtered to a single category |
/controlmedios/estadisticas/m/:medio | Filtered to a single outlet |
categoria and medio accordingly before processing statistics.
Data loading
On component initialisation,leerNoticias() fetches all press clipping records from WordPress. Once the data arrives, the component resolves human-readable outlet and program names by comparing each record’s identifiers against the XLS media catalog loaded at startup. Only after name resolution does procesarEstadisticas() run, so the charts always display the full display names rather than raw IDs.
EstadisticasComponent — default state
Chart types
All three charts share a single Chart.js configuration object:ChartOptions
barChartType and pieChartType are both declared on the component, but the dashboard renders bar charts exclusively. pieChartType is available for future use.Chart 1 — Mentions per media outlet (barMedios)
Populated from conteoMedios, which holds one entry per distinct outlet found in the filtered dataset.
Chart 2 — Mentions per program (barProgramas)
Populated from conteoProgramas, one entry per distinct program.
Chart 3 — Mentions per topic/category (barTopics)
Populated from conteoTopics, one entry per distinct topic tag.
#004b81 to visually distinguish it from the outlet and program charts.
How procesarEstadisticas() works
procesarEstadisticas() iterates over datosAProcesar (the currently filtered dataset) and builds the three count arrays in a single pass:
Apply active filters
The method starts from
datosAProcesar, which already reflects the active date range, category route parameter, and outlet route parameter. No further filtering happens inside the method itself.Count by outlet
For each record, the method looks up the resolved outlet name and increments the corresponding entry in
conteoMedios, or pushes a new { medio, cantidad: 1 } object if the outlet has not been seen yet.Count by program
The same accumulation logic runs for
conteoProgramas, keyed on the resolved program name.Count by topic
Topic tags are accumulated into
conteoTopics by iterating e.acf.topic — the array field on each WordPress record. Each element of the array is counted independently, so a record tagged with both Salud and Infraestructura increments both counters.Filtered views
Category filter
Navigate to/controlmedios/estadisticas/c/:cat to restrict all three charts to items tagged with :cat. The categoria field is set from the route parameter; procesarEstadisticas() then only counts records whose topic list includes that value.
Outlet filter
Navigate to/controlmedios/estadisticas/m/:medio to restrict all three charts to items from a single outlet. The medio field is set from the route parameter.
Filtering
Date range, category, and outlet filters in detail.
Export
Export filtered data as CSV or print as PDF.