Skip to main content
Before the dashboard renders its charts, procesarEstadisticas() applies the active set of filters to produce datosAProcesar — the working slice of data that drives every count and every export. Three independent filters are available: date range, category, and media outlet.

Date range filter

The date range filter is the primary way to narrow the dataset. Two date fields — desde (from) and hasta (to) — are bound to ng-bootstrap datepicker widgets (ngb-datepicker) and stored in DataService.

Default range

When the application initialises, DataService sets a default window of 30 days before today through 30 days after today:
DataService constructor
const hoy = new Date();
const fechaDesde = new Date(hoy.setDate(hoy.getDate() - 30));
const fechaHasta = new Date(hoy.setDate(hoy.getDate() + 30));

this.statsDesde = {
  year:  fechaDesde.getFullYear(),
  month: fechaDesde.getMonth() + 1,
  day:   fechaDesde.getDate()
};
this.statsHasta = {
  year:  fechaHasta.getFullYear(),
  month: fechaHasta.getMonth() + 1,
  day:   fechaHasta.getDate()
};
This means you see approximately two months of data on your first visit without any manual configuration.

Internal date format

Dates are stored as NgbDateStruct objects ({ year, month, day }) but compared as six-character strings in the format YYMMdd. The value is derived from the sendDate field on each record, which is stored in dd/mm/YY format:
Date normalisation
// Build the comparison keys from the filter controls
const fromDate =
  `${desde['year'].toString().slice(-2)}` +
  `${desde['month'].toString().padStart(2, '0')}` +
  `${desde['day'].toString().padStart(2, '0')}`;

const toDate =
  `${hasta['year'].toString().slice(-2)}` +
  `${hasta['month'].toString().padStart(2, '0')}` +
  `${hasta['day'].toString().padStart(2, '0')}`;

// Normalise each record's sendDate field (dd/mm/YY) to the same format
datosFiltrados = this.datos.filter((n) => {
  const fechatmp = n.acf.sendDate.split('/').reverse(); // ['YY', 'mm', 'dd']
  const fecha =
    `${fechatmp[0].toString().slice(-2)}` +
    `${fechatmp[1].toString().padStart(2, '0')}` +
    `${fechatmp[2].toString().padStart(2, '0')}`;
  return fecha >= fromDate && fecha <= toDate;
});
The comparison uses lexicographic ordering on the YYMMdd string, which works correctly as long as all dates fall within the same century. Records without a valid sendDate value are excluded automatically because their normalised string will not satisfy the range condition.

Applying a new date range

After you change the desde or hasta pickers, click Consultar to re-run the filter and refresh all three charts:
1

Open the date pickers

The desde and hasta fields appear above the charts. Click either field to open the ng-bootstrap calendar widget.
2

Select your dates

Navigate to the desired month and click a day to set the boundary. Both fields accept any valid calendar date.
3

Click Consultar

The Consultar() method reads the current statsDesde and statsHasta values from DataService, rebuilds fromDate and toDate, re-filters this.datos, and calls procesarEstadisticas() to repopulate the three count arrays and redraw the charts.

Category filter

Navigate to /controlmedios/estadisticas/c/:cat to restrict the dashboard to a single government-area category. The route parameter :cat is read on component init and stored in the categoria field (default: 'TOTALES').
Example routes
/controlmedios/estadisticas/c/SALUD
/controlmedios/estadisticas/c/OBRAS+PUBLICAS
When categoria is anything other than 'TOTALES', procesarEstadisticas() skips records whose topics field does not include that value. All three charts (outlets, programs, and topics) reflect only the matching records.
Category values must match the keyword group names configured in Google Sheets exactly, including accents and capitalisation.

Media outlet filter

Navigate to /controlmedios/estadisticas/m/:medio to restrict the dashboard to a single outlet. The route parameter :medio is read on init and stored in the medio field (default: 'TODOS').
Example routes
/controlmedios/estadisticas/m/LVI
/controlmedios/estadisticas/m/CANAL+10
When medio is anything other than 'TODOS', only records from that outlet are counted.

Filter interaction summary

FilterHow to activateDefault
Date rangedesde / hasta pickers + ConsultarLast 30 days → next 30 days
CategoryNavigate to /estadisticas/c/:catTOTALES (all categories)
OutletNavigate to /estadisticas/m/:medioTODOS (all outlets)
The category and outlet filters are route-based. Changing the date range and clicking Consultar does not reset them. If you navigated to a category or outlet route and then adjust the date pickers, the date filter is applied on top of the existing route filter.
Link directly to a pre-filtered view — for example /estadisticas/c/SALUD — in internal briefing documents so officials land on the correct category immediately.

Dashboard

Chart types and data loading overview.

Export

Export filtered data as CSV or print as PDF.

Build docs developers (and LLMs) love