feat(indicadores): habilitar dashboards Angular TEA CaCu y CaMa

This commit is contained in:
Angel Capetillo Zavala
2026-10-12 16:39:37 -06:00
parent a66205b725
commit b1c4b78f32
15 changed files with 5036 additions and 41 deletions
@@ -0,0 +1,31 @@
import { FigureSelection, PlotlyFigure } from './indicadores.models';
export function figureTitle(figure: PlotlyFigure, fallback: string): string {
const title = figure.layout['title'];
if (typeof title === 'string' && title.trim()) return title;
if (title && typeof title === 'object' && 'text' in title
&& typeof title.text === 'string' && title.text.trim()) return title.text;
return fallback;
}
// Adapt only the dashboard copy; HTTP figures and all observations stay intact.
export function presentationFigure(original: PlotlyFigure, selection: FigureSelection): PlotlyFigure {
const figure = structuredClone(original);
const title = figure.layout['title'];
figure.layout['title'] = title && typeof title === 'object' ? { ...title, text: '' } : { text: '' };
if ((selection.dominio === 'cacu' || selection.dominio === 'cama')
&& selection.figura === 'fig_c1_puntos' && selection.tipoPeriodo === 'mes'
&& figure.data.length > 0
&& figure.data.every(trace => trace['type'] === 'scatter' && trace['mode'] === 'markers'
&& Array.isArray(trace['x']) && trace['x'].length > 0
&& trace['x'].every(x => typeof x === 'string' && /^[0-9]{4}-(0[1-9]|1[0-2])$/.test(x)))) {
const periods = [...new Set(figure.data.flatMap(trace => trace['x'] as string[]))].sort();
figure.layout['xaxis'] = {
...(figure.layout['xaxis'] as Record<string, unknown> | undefined),
type: 'category', categoryorder: 'array', categoryarray: periods,
tickmode: 'array', tickvals: periods, ticktext: periods,
tickangle: 0, automargin: true,
};
}
return figure;
}