Salud IA Bot can respond to data queries not just with text, but with chart images sent directly into the Telegram conversation. The visualization pipeline is built onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/RubenDarioGuerreroNeira/Ecosistema-IA-Colombia/llms.txt
Use this file to discover all available pages before exploring further.
ChartService, which constructs a Chart.js configuration object, serializes it, and generates a QuickChart URL. The bot then calls ctx.replyWithPhoto(url) to deliver the PNG image inline — no file upload, no external app required.
Chart images are generated on-the-fly by QuickChart’s public API. Default dimensions are 500x300 pixels in PNG format. The horizontal bar chart helper overrides these to 600x350 to accommodate longer category labels.
How the chart system works
ChartService acts as a thin adapter between the bot’s analytics services and the QuickChart rendering API. It exposes one core method and four chart-type helpers:
generateChartUrl accepts any valid Chart.js config object, serializes it with JSON.stringify, encodes it with encodeURIComponent, and appends it to the QuickChart base URL alongside the width, height, and format parameters:
generateChartUrl. The generateHorizontalBarChart helper overrides the default dimensions to w=600&h=350.
Supported chart types
Bar chart
Vertical bar chart (
type: 'bar') with data labels above each bar. Used for rankings, event counts, and vaccination coverage comparisons. Fill color: rgba(54, 162, 235, 0.5).Doughnut chart
Doughnut chart (
type: 'doughnut') with percentage labels inside each segment. Uses a six-color palette. Used for gender distribution and proportional breakdowns. Called via generatePieChart.Horizontal bar chart
Horizontal bars (
type: 'horizontalBar') with percentage suffixes on axis ticks and data labels. Supports up to 18 distinct colors. Rendered at 600x350. Used for vaccination coverage by department.Line chart
Line chart (
type: 'line') with tension: 0.1 for smooth curves. Used for disease trends and time-series visualization.Air quality charts
Air quality data is drawn from theAirQualityService and covers municipalities across Colombia including Medellin, Cali, Bogota, Andes, and others in Antioquia and Valle del Cauca.
Mental health charts
Mental health charts visualize the CIE-10 diagnostic distribution loaded fromSalud_Mental.xml.
MentalHealthService.getTopDiagnoses(limit) provides the labels and values; ChartService.generateBarChart renders the image.
SIVIGILA / public health charts
Three chart variants are available for public health data:SaludPublicaService.compararSexo(evento) to get the femenino/masculino split, then pass the two values and percentage labels to generatePieChart (which renders a doughnut).
Vaccination charts
VaccinationService.getCoverageByDepartment(departamento) returns the coverage records. The horizontal bar chart format is used because vaccine names can be long and benefit from the extra width.
Cali services chart
CaliHealthService.getStatsByCategory() returns label/data pairs for the top six service groups by provider count, which are then passed to ChartService.generateBarChart.
Full chart generation flow
Intent detection
BotUpdate.onText detects chart-related keywords from GRAPHIC_KEYWORDS: graficar, grafico, graficar, visualizar, dibujar, mostrar grafico, puedes graficar, and similar variants.Data retrieval
The appropriate analytics service is called to obtain labels and numeric values (e.g. event names + case counts, indicator names + pollutant levels).
Chart config assembly
A Chart.js config object is assembled by the relevant
ChartService helper (generateBarChart, generatePieChart, generateHorizontalBarChart, or generateLineChart) with title, dataset colors, and plugin options for data labels.URL generation
generateChartUrl(config, options) serializes and URL-encodes the config, producing a https://quickchart.io/chart?w=...&h=...&f=...&c=... URL.