Skip to main content
The analytics dashboard is served by 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

RouteView
/controlmedios/estadisticasAll categories, all media (default)
/controlmedios/estadisticas/c/:catFiltered to a single category
/controlmedios/estadisticas/m/:medioFiltered to a single outlet
The component reads the active route parameters on init and sets 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
categoria: string = 'TOTALES'; // 'TOTALES' = no category filter
medio: string = 'TODOS';       // 'TODOS'   = no outlet filter

Chart types

All three charts share a single Chart.js configuration object:
ChartOptions
ChartOptions: ChartOptions = {
  responsive: true,
  plugins: {
    legend: { position: 'top' },
    title: { display: false }
  }
};
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.
conteoMedios: { medio: string; cantidad: number; }[] = [];
Each bar represents a resolved outlet display name on the X-axis and its mention count on the Y-axis.

Chart 2 — Mentions per program (barProgramas)

Populated from conteoProgramas, one entry per distinct program.
conteoProgramas: { programa: string; cantidad: number; }[] = [];
Program names are resolved the same way as outlet names — through the XLS catalog — so the chart reflects the catalog’s canonical names.

Chart 3 — Mentions per topic/category (barTopics)

Populated from conteoTopics, one entry per distinct topic tag.
conteoTopics: { topics: string; cantidad: number; }[] = [];
This chart uses a custom background colour of #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:
1

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.
2

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.
3

Count by program

The same accumulation logic runs for conteoProgramas, keyed on the resolved program name.
4

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.
5

Bind to charts

The three count arrays are then bound to the corresponding Chart.js dataset inputs, triggering a re-render of all three bar charts.

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.
You can combine the date range filter with either the category or outlet route to produce highly targeted chart data before exporting.

Filtering

Date range, category, and outlet filters in detail.

Export

Export filtered data as CSV or print as PDF.

Build docs developers (and LLMs) love