Componentes

Reusable Streamlit UI helpers for SIGAM views.

components.ui.load_css()

Load the project stylesheet into the current Streamlit page.

The function reads assets/style.css when it exists and injects it as unsafe HTML, which is the Streamlit mechanism used by the app for global styling.

components.ui.page_header(titulo, subtitulo='', icono='')

Render a standardized page header.

Parámetros:
  • titulo (str) – Main title shown in the header.

  • subtitulo (str) – Optional subtitle shown below the title.

  • icono (str) – Optional icon prefix for the title.

components.ui.kpi_card(valor, etiqueta, delta='', delta_positivo=True, color_borde='#1A3A6B')

Render a KPI card.

Parámetros:
  • valor – Value displayed as the card headline.

  • etiqueta (str) – Label describing the metric.

  • delta (str) – Optional comparison text.

  • delta_positivo (bool) – Whether the delta should use the positive style.

  • color_borde (str) – Top-border color used by the card.

components.ui.nivel_badge(nivel)

Return the HTML badge for a maturity level.

Parámetros:

nivel (str) – Maturity level label.

Devuelve:

HTML span string with the CSS class for the level.

Tipo del valor devuelto:

str

components.ui.mostrar_nivel(nivel)

Render a maturity-level badge in Streamlit.

Parámetros:

nivel (str) – Maturity level label.

components.ui.progress_steps(pasos, activo)

Render a horizontal step-progress indicator.

Parámetros:
  • pasos (list) – Step labels in display order.

  • activo (int) – Zero-based index of the current active step.

components.ui.alert_box(mensaje, tipo='info', icono='')

Render a styled alert message.

Parámetros:
  • mensaje (str) – Alert body text.

  • tipo (str) – Alert type key, such as info, success, warning, or danger.

  • icono (str) – Optional icon prefix.

Render the CGR logo in the Streamlit sidebar.

components.ui.sidebar_muni(nombre_muni)

Render the municipal portal navigation bar.

Parámetros:

nombre_muni (str) – Municipality name displayed in the navigation bar.

components.ui.sidebar_admin()

Render the Contraloria administrator navigation bar.

components.ui.gauge_score(score, titulo='IGSM')

Render a circular gauge for an IGSM score.

Parámetros:
  • score (float) – IGSM score in the 0-1 range.

  • titulo (str) – Gauge title.

Plotly chart builders used by SIGAM views.

components.charts._layout_base(fig, height=400)

Apply the shared SIGAM visual layout to a Plotly figure.

Parámetros:
  • fig – Plotly figure to style.

  • height – Figure height in pixels.

Devuelve:

The same Plotly figure with common layout properties applied.

components.charts.ranking_bar_chart(df, top_n=20)

Build a horizontal ranking chart for municipalities.

Parámetros:
  • df (pandas.DataFrame) – Ranking data with municipality, level, and total score columns.

  • top_n (int) – Number of municipalities to display from the top of the data.

Devuelve:

Plotly bar chart with municipalities grouped by maturity level.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.distribucion_niveles_pie(distribucion)

Build a donut chart for maturity-level distribution.

Parámetros:

distribucion (dict) – Mapping from maturity level to municipality count.

Devuelve:

Plotly pie chart with the configured maturity colors.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.radar_ejes(scores_eje, nombre='')

Build a radar chart for axis or service scores.

Parámetros:
  • scores_eje (dict) – Mapping from axis or service name to score in the 0-1 range.

  • nombre (str) – Trace label to display when legends are enabled.

Devuelve:

Plotly polar scatter figure.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.historico_lineas(historial_data, nombre='')

Build a line chart for historical IGSM scores.

Parámetros:
  • historial_data (dict) – Mapping from period label to score in the 0-1 range.

  • nombre (str) – Trace label for the historical series.

Devuelve:

Plotly line chart with score percentages.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.comparacion_servicios_bar(scores_servicios, promedio_nacional=None)

Build a service comparison bar chart.

Parámetros:
  • scores_servicios (dict) – Mapping from service name to municipal score.

  • promedio_nacional (dict) – Optional mapping from service name to national score.

Devuelve:

Plotly bar chart with optional national average markers.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.mapa_costa_rica(df)

Build a Costa Rica map colored by IGSM maturity level.

Parámetros:

df (pandas.DataFrame) – Municipality ranking data with latitude, longitude, score, and level.

Devuelve:

Plotly Mapbox scatter figure.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.heatmap_region_servicio(df)

Build a heatmap of average service scores by region.

Parámetros:

df (pandas.DataFrame) – Ranking data containing region and nested service score values.

Devuelve:

Plotly heatmap figure.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.scatter_dispersion(df, eje_x='score_total')

Build a municipality dispersion chart by score and relative position.

Parámetros:
  • df (pandas.DataFrame) – Ranking data with score, level, and position columns.

  • eje_x (str) – Compatibility argument retained by callers; the chart uses the total score percentage.

Devuelve:

Plotly scatter chart.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.barras_etapas(etapas)

Build a bar chart for stage scores.

Parámetros:

etapas (dict) – Mapping from stage name to score in the 0-1 range.

Devuelve:

Plotly bar chart with stage percentages.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts.cluster_chart(df)

Build a municipality cluster chart.

Parámetros:

df (pandas.DataFrame) – Ranking data with at least total score, region, level, and municipality columns.

Devuelve:

Plotly scatter chart with inferred or fallback cluster labels.

Tipo del valor devuelto:

plotly.graph_objects.Figure

components.charts._nivel_por_score(score)

Classify a numeric IGSM score into a maturity level.

Parámetros:

score (float) – IGSM score in the 0-1 range.

Devuelve:

Maturity level label.

Tipo del valor devuelto:

str