PageSourceSearch

https://inegi.org.mx/componentes/biinegi/exploradorv2.min.js?v1.1.10

js inegi.org.mx collected 2026-09-24 09:06:28 UTC 223,922 bytes, 4,278 lines download raw bytes

1/// <summary>   Idioma del componente. </summary>
2var expl_idioma = "";
3/// <summary>   Clave de indicador. </summary>
4var expl_indicador = "";
5/// <summary>   Clave de area geografica. </summary>
6var expl_ageo = "";
7var expl_ageomult = "";
8/// <summary>   Clave de area geografica convertida al nuevo formato. </summary>
9var expl_tratageo = "";
10/// <summary>   Año desplegado. </summary>
11var expl_uanio = "";
12/// <summary>   Bandera que indica que se ha terminado de cargar el componente. </summary>
13var expl_itbl = false;
14/// <summary>   Bandera que indica que es un indicador de BIE. </summary>
15var expl_bie = false;
16/// <summary>   Clave de tema padre. </summary>
17var expl_temaPadre = "";
18/// <summary>   Vista inicial del componente. </summary>
19var expl_vistaInicial = "grafica";
20/// <summary>   Permite mostrar mapa. </summary>
21var expl_permiteMapa = true;
22/// <summary>   Desglose geografico. </summary>
23var expl_desglose = "1";
24
25var expl_colorGlobal = "";
26var expl_selecAgeo = false;
27var expl_valor = "";
28var expl_nombre = "";
29var expl_verMetadato = false;
30var expl_inicia = true;
31var expl_tematica = "";
32
33var expl_precision = "false";
34var expl_esMunicipal = false;
35var expl_ageoCmb = "";
36var checaPerdiodoBusq = "";
37var expl_config = "v1_1";
38var expl_pais = false;
39var array_pais = [];
40var municipios = [];
41var expl_escala;
42
43
44var alterno_;
45(function () {
46    var version = "";
47    var fecha = "";
48    var autor = "";
49    var modified = "";
50    /// <summary>   Version y fecha de modificacion. </summary>
51    var about = function () {
52        this.version = 'INEGI';
53        this.version = '1.1.0';
54        this.ultima_modificacion = '02.07.2019';
55    };
56    /// <summary>   Genera instancia de la clase. </summary>
57    var exploradorDatos = function (params) {
58        return new Library(params);
59    };
60    /// <summary>   Inicializa variables de configuracion. </summary>
61    var Library = function (params) {
62        if (params) {
63            configura(params).init();
64            var selector = document.querySelectorAll(params),
65                i = 0;
66            this.length = selector.length;
67            this.id = selector[this.length - 1].id;
68            this.dominio = C_dominio;
69            this.tk = C_token;
70            if (document.domain === "localhost") {
71                this.imagen = C_libreriasAlpha;
72            }
73            else {
74                this.imagen = "/componentes/biinegi";
75            }
76            this.container = params;
77
78            this.servicio = C_direccionServicio_V + "_" + API_V;
79            this.dirGrafica = C_direccionServicio_V + "_" + API_V;
80            expl_config = API_V;
81
82            for (; i < this.length; i++) {
83                this[i] = selector[i];
84            }
85            return this;
86        }
87        else {
88            return about();
89        }
90    };
91
92
93    /// <summary>   Cuerpo de la clase. </summary>
94    exploradorDatos.fn = Library.prototype =
95    {
96        /// <summary>   Inicia variables de la clase y la plantilla. </summary>
97        /// <param name="idioma">       Idioma de la plantilla. </param>
98        /// <param name="indicador">    Clave de indicador. </param>
99        /// <param name="ageo">         Clave de area geografica. </param>
100        /// <param name="nombre">       Nombre del indicador. </param>
101        /// <param name="desglose">     Desglose geografico. </param>
102        /// <param name="periodo">      Periodo mostrado. </param>
103        /// <param name="periodoCorto"> Nombre de periodo corto. </param>
104        /// <param name="valor">        Valor del indicador. </param>
105        /// <param name="verMetadato">  Mostrar metadato. </param>
106        /// <param name="esBie">        Consultar en BIE. </param>
107        /// <param name="temaPadre">    Clave de tema padre. </param>
108        /// <returns>   . </returns>
109        init: function (idioma, indicador, ageo, nombre, desglose, periodo, periodoCorto, valor, verMetadato, esBie, temaPadre, vistaInicial, color, selecAgeo, tematica) {
110            var _this = this;
111            _this.cargaLibrerias();
112            checaPerdiodoBusq = periodo;
113            document.getElementById(_this.id).className = "classCarga";
114
115            if (desglose === "1" && tematica !== "3") {
116                selecAgeo = false;
117            }
118            //if (desglose === "1" && ageo === "0700" && tematica === "3" || desglose === "1" && ageo === "0" && tematica === "3") {
119            //    selecAgeo = false;
120            //}
121
122
123            setTimeout(function () {
124                expl_tematica = tematica !== undefined ? tematica : "6";
125                _this.dirGrafica = tematica !== undefined ? tematica : "6";
126
127                if (_this.servicio.toUpperCase().indexOf("V1_2") !== -1) {
128                    expl_tematica = expl_tematica === "0" ? "3" : expl_tematica;
129                }
130
131                if (_this.servicio.toUpperCase().indexOf("V1_1") !== -1) {
132                    expl_tematica = expl_tematica === "3" ? "0" : expl_tematica;
133                }
134
135                expl_idioma = idioma;
136                expl_colorGlobal = color === undefined ? "" : color;
137                expl_selecAgeo = selecAgeo === undefined || selecAgeo === "" ? false : JSON.parse(selecAgeo);
138                expl_indicador = indicador.toString();
139                expl_ageo = ageo;
140                expl_ageomult = ageo;
141                /*                expl_ageo_mapa = ageo;*/
142                expl_tratageo = _this.trataAg([ageo]);
143
144                //Valida si es un municipio
145                //expl_ageoCmb = desglose === "99" || desglose === "26" || desglose === "9"  ? ageo :( convert
145idorAreasGeo(_this.container).init(ageo));
146                expl_ageoCmb = desglose === "99" || desglose === "26" || desglose === "9"  ? ageo :( ageo);
147
148                //expl_esMunicipal = expl_ageoCmb.length === 12 ? true : false;
149                expl_esMunicipal = expl_ageoCmb.length === 5 ? true : false;
150                //
151
152                expl_uanio = periodo;
153                expl_uaniocorto = periodoCorto;
154                expl_bie = (esBie === undefined) ? false : esBie;
155                expl_temaPadre = temaPadre;
156                expl_vistaInicial = vistaInicial || "grafica";
157                expl_desglose = desglose.toString();
158                expl_valor = valor.trim();
159                expl_nombre = nombre.indexOf("|") !== -1 ? nombre.replace("|", ", ") : nombre;
160                expl_verMetadato = verMetadato;
161
162                if (expl_desglose === "1" && vistaInicial === "comparativo")
163                    expl_vistaInicial = "grafica";
164                if (expl_desglose === "3" && vistaInicial === "comparativo")
165                    expl_vistaInicial = "grafica";
166                _this.consultaTienePrecision(expl_indicador, expl_tematica, expl_ageoCmb);
167            }, 1500);
168        },
169
170        /// <summary>   Obtiene frecuencia para calcular escala. </summary>
171        /// <param name="indicador">    The indicador. </param>
172        /// <param name="ageo">         The ageo. </param>
173        /// <returns>   . </returns>
174        consultaTienePrecision: function (indicador, tematica, agr) {
175            var _this = this;
176            var ruta = _this.servicio + "/API.svc/indicadorPrecision/" + indicador + "/" + expl_tematica + "/json/" + _this.tk + "?callback=?";
177            $.getJSON(ruta, null, function (precision) {
178                _this.evento();
179                _this.goEstructura(expl_vistaInicial, indicador, precision, tematica, agr);
180                var content = "selecAgeoMultiple_" + _this.id;
181             
182                var params;
183
184                if (precision) {
185                    //19092024
186                    if (expl_desglose === "1") {
187
188                        if (agr === "0" && tematica === "3" || agr === "0" && tematica === "3") {
189                            _this.cargaInicial(expl_vistaInicial, indicador);
190                            expl_selecAgeo = false;
191                        }
192                        else {
193                            expl_selecAgeo = true;
194                        }
195                    }
196
197                    if (expl_selecAgeo) {
198                        _this.construyeCombosAgeo(expl_ageo, indicador);
199                    }
200
201                } else {
202
203                    if (expl_selecAgeo && tematica === "3") {
204                        _this.construyeCombosAgeo(expl_ageo, indicador);
205
206                        if (expl_desglose !== "4") {
207                            if (expl_vistaInicial === "grafica") {
208                                //if (expl_desglose === "1") {
209                                //    expl_selecAgeo = false;
210                                //    _this.cargaInicial(expl_vistaInicial, indicador);
211                                //}
212                                //else {
213                                $("#selecAgeo_" + _this.id).hide();
214
215                                content = "selecAgeoMultiple_" + _this.id;
216
217
218                                //params = {
219                                //    tematica: expl_tematica,
220                                //    lang: expl_idioma,
221                                //    ageo: expl_ageo,
222                                //    ind: indicador,
223                                //    alterno: _this.id,
224                                //    desglose: expl_desglose
225                                //};
226                                //cmbMultiCheck("#" + content).init(params);
227
228                                //14082024
229                                alterno_ = _this.id;
230                                params = {
231                                    "lang": expl_idioma,
232                                    "ageo": agr,
233                                    "principales": "1",
234                                    "tematica": expl_tematica,
235                                    "localidades": false,
236                                    "indicador": indicador,
237                                    "desglose": parseInt(expl_desglose),
238                                    "dobleUso": true,
239                                    "container": "#" + content
240                                };
241
242                                SitioINEGI_TreeAgeoCheck("#" + content).init(params);
243
244                                /*                       }*/
245                            }
246                        }
247                    }
248                    else if (expl_selecAgeo && expl_desglose !== "1") {
249
250                        if (expl_desglose === "2" || expl_desglose === "3") {
251                            _this.construyeCombosAgeo(expl_ageo, indicador);
252
253                            if (expl_vistaInicial === "grafica") {
254                                $("#selecAgeo_" + _this.id).hide();
255
256                                //content = "selecAgeoMultiple_" + _this.id;
257                                //params = {
258                                //    tematica: expl_tematica,
259                                //    lang: expl_idioma,
260                                //    ageo: expl_ageo,
261                                //    ind: indicador,
262                                //    alterno: _this.id,
263                                //    desglose: expl_desglose
264                                //};
265                                //cmbMultiCheck("#" + content).init(params);
266
267                                alterno_ = _this.id;
268                                params = {
269                                    lang: expl_idioma,
270                                    ageo: agr,
271                                    principales: "1",
272                                    tematica: expl_tematica,
273                                    localidades: false,
274                                    indicador: indicador,
275                                    desglose: parseInt(expl_desglose),
276                                    dobleUso: true,
277                                    container: "#" + content
278                                };
279
280                                SitioINEGI_TreeAgeoCheck("#" + content).init(params);
281
282                            }
283
284                        }
285                        else {
286                            expl_selecAgeo = false;
287                            _this.cargaInicial(expl_vistaInicial, indicador);
288                        }
289                    }
290                    else {
291                        if (expl_selecAgeo) {
292                            _this.construyeCombosAgeo(expl_ageo, indicador);
293                        }
294                        else {
295                            _this.cargaInicial(expl_vistaInicial, indicador);
296                        }
297                    }
298                }
299            });
300        },
301
302        /// <summary>   Dibuja plantilla de botones. </summary>
303        /// <returns>   . </returns>
304        goEstructura: function (vistaInicial, indicador, precision, tematica, agr) {
305            var _this = this;
306            var html = "";
307            var iconstext = expl_idioma === "es" ? "Exportar como " : "Export as ";
308            var menutext = expl_idioma === "es" ? "Opciones" : "Options";
309            var anchoTabla = precision === true ? "auto" : "280px;";
310            var contenedor = _this.container;
311            var visibleComparativo = "";
312
313            var txtAgeo_ = expl_idioma === "es" ? "Área geográfica" : "Geographic area";
314            //if (expl_desglose === "1" || expl_desglose==="3")
315
316            //12072024
317            if (expl_desglose === "1" || expl_desglose === "4" || expl_desglose === "9" || expl_desglose === "99" || expl_desglose === "26")
318                visibleComparativo = " style=\"display:none;\"";
319
320
321            var botonesExportaDatos = "";
322
323            //botonesExportaDatos = "<div class=\"col-xs-12\" style='padding:0px!important;'><div id=\"divExportarExpl" + _this.id + "\" class=\" text-right\" style=\"display: none;\"><img alt=\"xls\" id=\"btn_exportaXLSdivComponente\" style=\"curs
323or: pointer; margin-right:5px;\" onclick=\"javascript:exploradorDatos(\'' + contenedor + '\').trataExportacion('xls','" + indicador + "','" + contenedor + "'," + precision + ");\" src=\"/img/ico/ico_xls.png\"><img id=\"btn_exportaCSVdivComponente\" style=\"cursor: pointer;margin-right:5px;\" onclick=\"javascript:exploradorDatos(\'' + contenedor + '\').trataExportacion('csv','" + indicador + "','" + contenedor + "'," + precision + "); \" src=\"/img/ico/ico_CSV.png\" alt=\"CSV\"><img alt=\"pdf\" id=\"btn_exportaPDFdivComponente\" style=\"cursor: pointer; margin-right:5px; display:none;\" onclick=\"javascript:exploradorDatos(\'' + contenedor + '\').trataExportacion('pdf','" + indicador + "','" + contenedor + "'," + precision + ");\" src=\"/img/ico/ico_pdf.png\"><div id=\"divExportarExpl" + _this.id + "\" class=\" text-right\" style=\"display: none;\"></div></div>";
324            //html += "<div class=\"classCarga\" id=\"gralDivExpl_" + _this.id + "\">";
325            //html += "<div class=\"fluid topExpl\" id=\"divgral_" + indicador + "\" style=\"display:none\"><div role=\"main\">";
326
327            botonesExportaDatos += "<div class=\"col-xs-12\" style='padding:0px!important;'><div class=\"pull-right btn-group\" style=\"margin-top:25px; margin-right:15px;\" id=\"divExportarExpl" + _this.id + "\" class=\" text-right\" style=\"display: none;\">";
328            botonesExportaDatos += "<button type=\"button\" class=\"btn dropdown-toggle btnMenuOpcionesChart cls-tooltip\" aria-haspopup=\"true\" data-original-title=\"" + menutext + "\" data-placement=\"top\" data-toggle=\"dropdown\"><span class=\"inegi-icono inegi-menu\" aria-hidden=\"true\"></span></button>";
329
330
331            //botonesExportaDatos += "<ul class=\"dropdown-menu\" role=\"menu\" style=\"min-width: 100px\"><li><a data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"" + iconstext + "XLS\"><img id=\"btn_exportaXLSdivComponente\" style=\"cursor: pointer; margin-right:5px;\" onclick=\"javascript:exploradorDatos(\'' + contenedor + '\').trataExportacion('xls','" + indicador + "','" + contenedor + "'," + precision + ");\" src=\"/img/ico/ico_xls.png\"></a></li>";
332
333            botonesExportaDatos += "<ul class=\"dropdown-menu\" role=\"menu\" style=\"min-width: 100px\"><li><a data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"" + iconstext + "XLS\"><img id=\"btn_exportaXLSdivComponente\" style=\"cursor: pointer; margin-right:5px;\" onclick=\"javascript:exploradorDatos('" + contenedor + "').trataExportacion('xls','" + indicador + "','" + contenedor + "'," + precision + ");\" src=\"/img/ico/ico_xls.png\"></a></li>";
334            //botonesExportaDatos += "<li><a data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"" + iconstext + "CSV\"><img id=\"btn_exportaCSVdivComponente\" style=\"cursor: pointer;margin-right:5px;\" onclick=\"javascript:exploradorDatos(\'' + contenedor + '\').trataExportacion('csv','" + indicador + "','" + contenedor + "'," + precision + "); \" src=\"/img/ico/ico_CSV.png\"></a></li>";
335            botonesExportaDatos += "<li><a data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"" + iconstext + "CSV\"><img id=\"btn_exportaCSVdivComponente\" style=\"cursor: pointer;margin-right:5px;\" onclick=\"javascript:exploradorDatos('" + contenedor + "').trataExportacion('csv','" + indicador + "','" + contenedor + "'," + precision + "); \" src=\"/img/ico/ico_CSV.png\"></a></li>";
336            //botonesExportaDatos += "<li style='display:none;'><a><img id=\"btn_exportaPDFdivComponente\" style=\"cursor: pointer; margin-right:5px; display:none;\" onclick=\"javascript:exploradorDatos(\'' + contenedor + '\').trataExportacion('pdf','" + indicador + "','" + contenedor + "'," + precision + ");\" src=\"/img/ico/ico_pdf.png\"></a></li>";
337
338            botonesExportaDatos += "<li style='display:none;'><a><img id=\"btn_exportaPDFdivComponente\" style=\"cursor: pointer; margin-right:5px; display:none;\" onclick=\"javascript:exploradorDatos('" + contenedor + "').trataExportacion('pdf','" + indicador + "','" + contenedor + "'," + precision + ");\" src=\"/img/ico/ico_pdf.png\"></a></li>";
339            botonesExportaDatos += "</ul >";
340            botonesExportaDatos += "<div id=\"divExportarExpl" + _this.id + "\" class=\" text-right\" style=\"display: none;\">";
341            botonesExportaDatos += "</div></div>";
342
343
344            html += "<div class=\"classCarga\" id=\"gralDivExpl_" + _this.id + "\">";
345            html += "<div class=\"fluid topExpl\" id=\"divgral_" + indicador + "\" style=\"display:none\"><div role=\"main\">";
346
347            if (expl_selecAgeo !== true || expl_desglose !== "2" && expl_desglose !== "3") {
348                if (expl_nombre !== "") {
349                    html += "<div class=\"col-xs-12\"><label class=\"titulo_indExpl notranslate\" id=\"titulo_ind" + _this.id + "\"></label><label class=\"titulo_indExpl\" id=\"titulo_per" + _this.id + "\" style=\"display:none;\"></label></div>";
350                }
351            }
352
353            html += "<div><div><div class=\"panel panel-default noBorde\"><div>";
354            html += "<div ><div >";
355
356            //Combos área geográfica
357            if (expl_selecAgeo) {
358                //AMCR-17092019
359                html += "<div id=\"selecAgeo_" + _this.id + "\"></div>";
360
361                //14082024
362                /*html += "<div id=\"selecAgeoMultiple_" + _this.id + "\"></div>";*/
363                //html += "<div id=\"selecAgeoMultiple_" + _this.id + "\">";
364
365                //v1
366                //html += "<div>";
367
368                //html += "<div class=\"_filterBox\">";
369                //html += "<div class=\"_box\">";
370                //html += "<div class=\"_boxhead\" id=\"drop_ageo\" data-toggle=\"collapse\" aria-expanded=\"false\" data-target=\"#bodyAgeo\" onclick=\"appCode.filterAgeo(this.id);\">";
371                //html += "<div class=\"_boxtitle\">Área geográfica</div>";
372                //html += "<div>";
373                //html += "<span id=\"spanageo\" class=\"inegi-flecha-abajo\" style=\"margin-left: 5px;\"></span>";
374                //html += "</div>";
375                //html += "</div>";
376                //html += "<div class=\"_boxbody collapse\" id=\"bodyAgeo\">";
377                //html += "<div class=\"_bdy _load\" id=\"selecAgeoMultiple_" + _this.id +"\"></div>";
378                //html += "</div>";
379                //html += "</div>";
380                //html += "</div>";
381
382                //html += "</div>";
383
384                //////
385                //v2
386                html += "<div class=\"btn-group anch\" id=\"treeageo_" + _this.id +"\">";
387                html += "<button id=\"cmp_ageo_\" class=\"btn btn-gray dropdown-toggle combos_multi\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">";
388                html += "<span>"+txtAgeo_+"</span>"; 
389                html += "<span class=\"inegi-flecha-abajo spandrop dchaa\"></span>";
390                html += "</button>";
391                html += "<div aria-labelledby=\"cmp_ageo_\" class=\"dropdown-menu pull-left menudrop dmenu_multi\" onclick=\"exploradorDatos('" + contenedor + "').onclickAgeo(event);\">";
392                html += "<div class=\"_bdy _load\" id=\"selecAgeoMultiple_" + _this.id + "\"></div>";
393                html += "</div>";
394                html += "</div>";
395            }
396            //end combos 'area geográfica
397
398            html += "<div class=\"btn-group derechaExpl menubuttons\" id=\"botonesExpl" + _this.id + "\">";
399            html += "<button id=\"btn_metadatoinfo" + _this.id + "\" type=\"button\" onclick=\"javascript:exploradorDatos('" + contenedor + "').btnGo('btn_metadatoinfo" + _this.id + "','" + indicador + "',event);\" class=\"btn btn-default btn-md\" aria-label=\"Botón metadato\"  data-toggle=\"tooltip\" data-original-title=\"" + (expl_idioma === "es" ? "Metadato" : "Metadata") + "\">";
400            html += "<span class=\"inegi-info\" aria-hidden=\"true\" style=\"font-size:18pt !important;\"></span></button>";
401            html += "<button id=\"btn_grafica" + _this.id + "\" type=\"button\" onclick=\"javascript:exploradorDatos('" + contenedor + "').btnGo('btn_grafica" + _this.id + "','" + indicador + "',event);\" class=\"btn btn-default btn-md\" aria-label=\"Gráfica\"  data-toggle=\"tooltip\" data-original-title=\"" + (expl_idioma === "es" ? "Gráfica" : "Chart") + "\">";
402            html += "<span class=\"inegi-grafica-linea\" aria-hidden=\"true\" style=\"font-size:18pt !important;\"></span></button>";
403            html += "<button id=\"btn_tabla" + _this.id + "\" type=\"button\" onclick=\"javascript:exploradorDatos('" + contenedor + "').btnGo('btn_tabla" + _this.id + "','" + indicador + "',event);\" class=\"btn btn-default btn-md\" aria-label=\"Tabla\"  data-toggle=\"tooltip\" data-original-title=\"" + (expl_idioma === "es" ? "Tabla" : "Table") + "\">";
404            html += "<span class=\"inegi-tabla\" aria-hidden=\"true\" style=\"font-size:18pt !important;\"></span></button>";
405            html += "<button id=\"btn_comparativo" + _this.id + "\" " + visibleComparativo + " type=\"button\" onclick=\"javascript:exploradorDatos('" + contenedor + "').btnGo('btn_comparativo" + _this.id + "','" + indicador + "',event);\" class=\"btn btn-default btn-md\" aria-label=\"Comparativo\"  data-toggle=\"tooltip\" data-original-title=\"" + (expl_idioma === "es" ? "Comparativo" : "Comparative") + "\">";
406            html += "<span class=\"inegi-top\" aria-hidden=\"true\" style=\"font-size:18pt !important;\"></span></button>";
407            var displayCalc = "display:none;";
408            if (expl_temaPadre !== undefined)
409                if (expl_temaPadre.substring(0, 4) === "1120") {
410                    displayCalc = "";
411                }
412            html += "<button id=\"btn_calc" + _this.id + "\" type=\"button\" onclick=\"javascript:exploradorDatos('" + contenedor + "').btnGo('btn_calc" + _this.id + "','" + indicador + "',event);\" class=\"btn btn-default btn-md\" style=\"" + displayCalc + "padding-left:10px !important; padding-right:10px; !important\" aria-label=\"Cálculos\"  data-toggle=\"tooltip\" data-original-title=\"" + (expl_idioma === "es" ? "Mapa" : "Map") + "\">";
413            html += "<span class=\"glyphicon_site inegi-calcest-act\" aria-hidden=\"true\" style=\"font-size:19pt !important; line-height:0.9 !important;\"></span></button>";
414
415            html += "<button id=\"btn_mapa" + _this.id + "\" type=\"button\" onclick=\"javascript:exploradorDatos('" + contenedor + "').btnGo('btn_mapa" + _this.id + "','" + indicador + "',event);\" class=\"btn btn-default btn-md\" style=\"padding-left:10px !important; padding-right:10px; !important\" aria-label=\"Mapa\"  data-toggle=\"tooltip\" data-original-title=\"" + (expl_idioma === "es" ? "Mapa" : "Map") + "\">";
416            html += "<span class=\"glyphicon_site inegi-mapa\" aria-hidden=\"true\" style=\"font-size:19pt !important; line-height:0.9 !important;\"></span></button>";
417
418            html += "<button id=\"btn_tablero" + _this.id + "\" type=\"button\" onclick=\"javascript:exploradorDatos('" + contenedor + "').btnTablero('btn_tablero" + _this.id + "','" + indicador + "',event);\" class=\"btn btn-default btn-md\" style=\"padding-left:10px !important; padding-right:10px; !important\" aria-label=\"Tablero\"  data-toggle=\"tooltip\" data-original-title=\"" + (expl_idioma === "es" ? "Tablero" : "Board") + "\">";
419            html += "<span class=\"glyphicon_site inegi-tablero\" aria-hidden=\"true\" style=\"font-size:19pt !important; line-height:0.9 !important;\"></span></button>";
420
421
422            html += "</div></div>";
423            html += botonesExportaDatos + "<div id=\"nombreInd" + _this.id + "\" style='display:none;'></div>";
424            html += "</div>";
425            html += "</div>";
426
427            html += "<div class=\"panel-bodyExpl siBorde\" >";
428            html += "<div class=\"row topExpl\">";
429            html += "<div class=\"col-xs-12\">";
430            html += "<div id=\"divTablaExpl" + _this.id + "\" style=\"display:block;\"><div class=\"row\"><div></div><div class=\"col-xs-12\"><div id=\"divT" + _this.id + "\" style=\"height:auto; overflow-y:hidden;
430 width:" + anchoTabla + " display: block;\"></div>";
431            html += "</div><div class=\"col-xs-3\"></div></div></div>";
432            html += "<div id=\"divGraficaExpl" + _this.id + "\" style=\"padding-left:10px; padding-right:10px;\"></div>";
433            html += "<div id=\"divComparativoExpl" + _this.id + "\" style=\"padding-left:10px; padding-right:10px;\"><div id=\"divGrafComp" + _this.id + "\"></div></div>";
434            html += "<div id=\"divTableroExpl" + _this.id + "\" style=\"padding-left:10px; padding-right:10px;display:none;\"><div id=\"divTableroComp" + _this.id + "\"></div></div>";
435
436            //Para llamar al compoente de beta
437            html += "<div id=\"divCalcExpl" + _this.id + "\"></div>";
438
439            html += "<div id=\"divMapaExpl" + _this.id + "\" class=\"divdemapa\">";
440            //html += "<div id=\"mapaTematico" + _this.id + "\" data-maptem=\"1\" class=\"mapTem\" style=\"width:100%\"></div> ";
441            html += "<div id=\"componenteMapa" + _this.id + "\" data-maptem=\"1\" class=\"mapTem container\" style=\"width:100%; heigth:524px;\"></div> ";
442            html += "</div>";
443
444            html += "<div>";
445            html += "<div  id=\"r_metadatoExpl" + _this.id + "\" style=\"display:none\"><div id=\"divMetadatoExpl" + _this.id + "\"></div></div>";
446            html += "</div>";
447
448            html += "<div id=\"divCalInpExpl" + _this.id + "\" ></div> ";
449
450            html += "</div>";
451
452            html += "</div></div>";
453
454            html += "</div></div></div></div></div></div></div></div>";
455
456            //IFRAME exporta
457            html += "<iframe id=\"ifExportaMC\" style='display:none'></iframe>";
458            html += "<div style='display:none' id=\"precision_" + _this.id + "\">" + precision + "</div>";
459            html += "<div style='display:none' id=\"up_" + _this.id + "\"></div>";
460            html += "<div style='display:none' id=\"exp_" + _this.id + "\"></div>";
461            html += "<div style='display:none' id=\"agr_" + _this.id + "\">" + agr + "</div>";
462            html += "<div style='display:none' id=\"titletablero_" + _this.id + "\"></div>";
463            html += "<div style='display:none' id=\"help_" + _this.id + "\">" + indicador + "_" + tematica + "</div>";
464            html += "<div style='display:none' id=\"haynacional_" + _this.id + "\">true</div>";
465            html += "<div style='display:none' id=\"uno_" + _this.id + "\">null</div>";//29012026
466
467
468            if (document.getElementById(_this.id) !== null) {
469                document.getElementById(_this.id).innerHTML = html;
470                document.getElementById(_this.id).className = "";
471            } 
472
473            setTimeout(function () {
474                function callbackMapa(mutationList) {
475                    mutationList.forEach(function (mutation) {
476                        if (mutation.type === "attributes") {
477                            /*  if (mutation.target.id.startsWith('svg_mapa')) {*/
478                            /*  if (mutation.target.id.startsWith('svg_')) {*/
479                            if (mutation.target.id.startsWith('Capa_1')) {
480                                if (document.getElementById("btn_mapa" + _this.id).disabled !== "false") {
481                                    $("#btn_mapa" + _this.id).attr("disabled", false);
482                                }
483                            }
484                        }
485                    });
486
487                }
488                // instancia Observador
489                let observer = new MutationObserver(callbackMapa);
490                //var config = { attributes: true, childList: true, subtree: true };
491                var config = { attributes: true, childList: false, subtree: true };
492                // elemento objetivo
493                var divContenido = document.getElementById("componenteMapa" + _this.id);
494                //ejecuta
495
496                if (divContenido !== null) {
497                    observer.observe(divContenido, config);
498                }
499            }, 3000);
500
501
502
503            var display = _this.validaComparativo();
504            if (document.getElementById("btn_comparativo" + _this.id) !== null) {
505                document.getElementById("btn_comparativo" + _this.id).style.display = display;
506            }
507        },
508        onclickAgeo: function (e) {
509            e.stopPropagation();
510        },
511        validaComparativo: function () {
512            var _this = this;
513            //29012026
514            var unDato = document.getElementById("uno_" + _this.id).innerText.trim();
515
516            var ver = "block";
517
518            if (expl_desglose === "4" || expl_desglose === "1" || expl_desglose === "9" || expl_desglose === "99" || expl_desglose === "26") {
519                ver = "none";
520            }
521            if (expl_pais === true && expl_desglose === "1") {
522                ver = "block";
523            }
524            //29012026
525            if (unDato !== "null") {
526                if (unDato === "true") {
527                    ver = "none";
528                }
529            }
530
531            return ver;
532        },
533        cargaInicial: function (vista, indicador) {
534            var _this = this;
535            _this.checaMapa(expl_ageo, expl_valor, expl_desglose);
536            _this.traePeriodos(expl_valor, expl_ageo, indicador, vista);
537
538            if (expl_selecAgeo !== true) {
539                if (expl_nombre !== "") {
540                    document.getElementById("titulo_ind" + _this.id).innerText = expl_nombre;
541                    document.getElementById("titulo_per" + _this.id).innerHTML = ", " + expl_uanio;
542                    document.getElementById("titulo_per" + _this.id).innerText = ", " + expl_uanio;
543                }
544            }
545
546
547            if (expl_verMetadato) {
548                var element = document.getElementsByName("tabMCcollapse-Indicadores");
549                if (element !== null) {
550                    document.location.href = "#tabMCcollapse-Indicadores";
551                }
552                else {
553                    document.location.href = "#divMapaExpl" + _this.id;
554                }
555            }
556        },
557
558        construyeCombosAgeo: function (entidad, indicador) {
559
560            var _this = this;
561            var content = "";
562            var filtrosAdicionales = "";
563            if (_this.servicio.toUpperCase().indexOf("V1_3") !== -1) {
564                if (expl_selecAgeo) {
565                    if (expl_desglose != "1" && expl_desglose != "9" && expl_desglose != "99" && expl_desglose != "26" || expl_tematica === "3") {
566                        content = "selecAgeo_" + _this.id;
567                        filtrosAdicionales = "1";
568                        areaGeo_Component(_this.container).init(entidad, indicador, expl_desglose, filtrosAdicionales, expl_tematica, "combos", content, expl_ageo);
569                    }
570                    else {
571                        _this.cargaInicial(expl_vistaInicial, indicador);
572                    }
573                }
574            }
575            else {
576                if (expl_desglose != "1") {
577                    content = "selecAgeo_" + _this.id;
578                    filtrosAdicionales = "1";
579                    areaGeo_Component(_this.container).init(entidad, indicador, expl_desglose, filtrosAdicionales, expl_tematica, "combos", content, expl_ageo);
580                }
581                else {
582                    _this.cargaInicial(expl_vistaInicial, indicador);
583                }
584            }
585        },
586        /// <summary>   Agrega ceros a claves de entidades. </summary>
587        /// <param name="ageo"> Clave de area geografica. </param>
588        /// <returns>   . </returns>
589        rellenaAgeo: function (ageo) {
590            var cobertura = ageo;
591            if (ageo.length === 2) {
592                cobertura = ageo + "000";
593            }
594            return cobertura;
595        },
596
597        /// <summary>   Cambia el formato de area geografica al nuevo formato de 2 digitos por entidad mas 3 por municipio. </summary>
598        /// <param name="ageo"> Clave de area geografica. </param>
599        /// <returns>   . </returns>
600        trataAg: function (ageo) {
601            var cobertura = [];
602            for (var ag = 0; ag < ageo.length; ag++) {
603                //Nacional
604                //if (ageo[ag].length == 4) {
605                //cobertura.push(parseInt(ageo[ag]) + "|0");
606                cobertura.push(ageo[ag] + "|0");
607                //}
608
609                //Entidad
610                //if (ageo[ag].length == 8) {
611                //cobertura.push(parseInt(ageo[ag]) + "|0");
612                //   cobertura.push(ageo[ag] + "|0");
613                //}
614                //Municipio
615                //if (ageo[ag].length == 12) {
616                //cobertura.push(parseInt(ageo[ag].substring(0, 2)) + "|" + parseInt(ageo[ag].substring(2, 5)));
617                //    cobertura.push(ageo[ag].substring(0, 2)) + "|" + parseInt(ageo[ag].substring(2, 5)));
618                //}
619                //Localidad
620                //if (ageo[ag].length == 9) {
621                //    cobertura.push(parseInt(ageo[ag].substring(0, 2)) + "|" + parseInt(ageo[ag].substring(2, 5)) + "-" + parseInt(ageo[ag].substring(5, 9)));
622                //}
623            }
624            return cobertura;
625        },
626
627        /// <summary>   Muestra u oculta el boton de ver mapa. </summary>
628        /// <param name="areageo">  Clave de area geografica. </param>
629        /// <param name="valor">    Valor del indicador. </param>
630        /// <param name="desglose"> Desglose geografico. </param>
631        /// <returns>   . </returns>
632        checaMapa: function (areageo, valor, desglose) {
633            var _this = this;
634            var pinta = false;
635            //validación para tm=3
636            var esBIEE = JSON.parse(expl_bie) === true ? (expl_tematica === "3" ? false : JSON.parse(expl_bie)) : JSON.parse(expl_bie);
637            var tempAgeo = _this.obtieneClaveAgeo("municipal");
638            var hayNacional = document.getElementById("haynacional_" + _this.id).innerText.trim();
639            //29012026
640            var unDato = document.getElementById("uno_" + _this.id).innerText.trim();
641
642            //24112025
643            /*if (hayNacional === "true") {*/
644                if (desglose === "4" || desglose === "9" || desglose === "99" || desglose === "26") {
645                    pinta = false;
646                } else {
647                    if (tempAgeo.length === 9 || esBIEE === true) {
648                        //Es localidad            
649                        pinta = false;
650                    }
651                    else {
652                        if (valor !== "") {
653                            if (tempAgeo === "00") {
654                                //Es Nacional            
655                                if (parseInt(desglose) > 1) {
656                                    pinta = true;
657                                }
658                                else {
659                                    pinta = false;
660                                }
661                            }
662                            else {
663                                if (parseInt(desglose) >= 2) {
664                                    if (unDato !== "null") {
665                                        if (unDato === "true") {
666                                            pinta = false;
667                                        } else {
668                                            pinta = true;
669                                        }
670                                    } else {
671                                        pinta = true;
672                                    }
673                                    
674                                }
675                                else {
676                                    pinta = false;
677                                }
678                            }
679                        }
680                        else {
681                            pinta = false;
682                        }
683                    }
684                }
685           /* }*/
686            //else {
687            //    pinta = false;
688            //}
689
690            expl_permiteMapa = pinta;
691            if (pinta) {
692                document.getElementById("btn_mapa" + _this.id).style.display = "inline";
693            }
694            else {
695                document.getElementById("btn_mapa" + _this.id).style.display = "none";
696            }
697        },
698
699        /// <summary>   Invoca componente del metadato y cambia la vista desplegada. </summary>
700        /// <param name="indicador">    Clave de indicador. </param>
701        /// <param name="ageo">         Clave de area geografica. </param>
702        /// <returns>   . </returns>
703        goMetadato: function (indicador, ageo) {
704            if (document.getElementById("divMetadatoExpl" + _this.id).innerHTML === "") {
705
706
707
708
709                if (indicador.length > 0 && ageo.length > 0) {
710                    muestraInfo = true;
711                    //metadatoControlV3("#divMetadatoExpl"+_this.id).init(ageo.toString(), indicador, 0, expl_idioma, false, expl_bie);
712                    metadatoControlV3("#divMetadatoExpl" + _this.id).init(ageo.toString(), indicador, 0, expl_idioma, false, expl_bie, expl_tematica);
713                    setTimeout(function () { document.getElementById("r_metadatoExpl" + _this.id).style.display = "block"; }, 2000);
714                }
715                else {
716                    muestraInfo = false;
717                    document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
718                }
719            }
720        },
721
722        /// <summary>   Consulta lista de periodos del indicador. </summary>
723        /// <param name="valor">        Valor del indicador. </param>
724        /// <param name="ageo">         Clave de area geografica. </param>
725        /// <param name="indicador">    Clave de indicador. </param>
726        /// <returns>   . </returns>
727        traePeriodos: function (valor, ageo, indicador, vista) {
728            var _this = this;
729            //var dirGSA = _this.servicio.toUpperCase().indexOf("V1_2") !== -1 ? (this.servicio + "/API.svc/Periodo/" + ageo + "/null/null/null/null/null/" + indicador + "/null/null/null/" + expl_tematica + "/json/" + _this.tk + "?callback=?") : (this.servicio + "/API.svc/Periodo/" + ageo + "/null/null/null/null/null/" + indicador + "/null/null/null/json/" + _this.tk + "?callback=?");
730            var tematica = (document.getElementById("help_" + _this.id).innerHTML.trim()).split("_")[1];
731            var tempAgeo = _this.servicio.toUpperCase().indexOf("V1_3") !== -1 && tematica === "3" ? "null" : ageo;
732
733            var dirGSA = _this.servicio.toUpperCase().indexOf("V1_2") !== -1 || _this.servicio.toUpperCase().indexOf("V1_3") !== -1 ? (_this.servicio + '/API.svc/PeriodoA/' + tempAgeo + '/null/null/es/0/0/' + indicador + '/null/null/null/' + tematica + '/json/' + _this.tk + '?callback=?') : (_this.servicio + '/API.svc/PeriodoA/' + ageo + '/null/null/es/0/0/' + indicador + '/null/null/null/json/' + _this.tk + '?callback=?');
734
735            if (dirGSA.length > 250) {
736                var parametrosPeriodo = {
737                    areaGeografica: _this.servicio.toUpperCase().indexOf("V1_2") !== -1 || _this.servicio.toUpperCase().indexOf("V1_3") !== -1 ? tempAgeo : ageo,
738                    tema: "null",
739                    indicadoresPrincipales: "null",
740                    idioma: "es",
741                    programa_ciclo: "0",
742                    ambito_Sec: "0",
743                    indicadoresSeleccionados: indicador,
744                    letra: "null",
745                    busqueda: "null",
746                    frecuencia: "null",
747                    tematica: tematica,
748                    formato: "json",
749                    token: _this.tk
750                };
751
752                var paramPer = JSON.stringify(parametrosPeriodo);
753                $.ajax({
754                    method: "POST",
755                    url: _this.servicio + '/API.svc/PeriodoA',
756                    contentType: "application/json; charset=utf-8",
757                    dataType: "json",
758                    data: paramPer,
759                    processData: true,
760                    success: function (data) {
761                        _this.callbackPeriodos(data, valor, vista, indicador);
762                    },
763                    error: function (jqXHR, textStatus, errorThrown) {
764                        console.log(textStatus, errorThrown);
765                    }
766                });
767            }
768            else {
769                $.getJSON(dirGSA, null, function (data) {
770                    _this.callbackPeriodos(data, valor, vista, indicador);
771                });
772            }
773        },
774
775        /// <summary>   Obtiene primer y ultimo periodo del indicador. </summary>
776        /// <param name="data">     Datos de los periodos en JSON. </param>
777        /// <param name="ultimo">   Ultimo valor del indicador. </param>
778        /// <returns>   . </returns>
779        callbackPeriodos: function (data, ultimo, vista, indicador) {
780            var _this = this;
781            var muestra = true;
782            var numero = _this.remueve(ultimo);
783            var excepcion = isNaN(numero.toString());
784            if (data.ErrorCode === undefined) {
785                var ultimoP = data[data.length - 1];
786                document.getElementById("up_" + _this.id).innerText = ultimoP;
787
788                if (data.length === 1) {
789                    if (excepcion || ultimo === "0" || ultimo === "0.0" || ultimo === "") {
790                        muestra = false;
791                    }
792                }
793                //var espacioEscala = 1;
794                //if (!expl_selecAgeo) {
795                _this.explora(muestra, vista, indicador);
796                //}
797            }
798            else {
799                var contenedor = _this.container;
800                muestra = false;
801                if (document.getElementById("divMetadatoExpl" + _this.id) !== null) {
802                    $("#divMetadatoExpl" + _this.id)[0].innerHTML = "";
803                }
804                $(contenedor)[0].innerHTML = "Ocurrió un error inesperado, favor de intentar más tarde";
805                _this.registraEvento();
806            }
807            // _this.explora(muestra);
808        },
809
810        /// <summary>   Quita un valor de una cadena separada por coma. </summary>
811        /// <param name="cadena">   Valores separados por coma. </param>
812        /// <returns>   . </returns>
813        remueve: function (cadena) {
814            var _this = this;
815            var resultado = _this.replaceAll(cadena, ",", "");
816            var resultado2 = _this.replaceAll(resultado, " ", "");
817            resultado2 = _this.replaceAll(resultado2, ".", "");
818            return resultado2;
819        },
820
821        replaceAll: function (str, find, replace) {
822            var _this = this;
823            return str.replace(new RegExp(_this.escapeRegExp(find), 'g'), replace);
824        },
825
826        /// <summary>   Despliega la grafica o tabla. </summary>
827        /// <param name="pintaGrafica"> Mostrar grafica. </param>
828        /// <returns>   . </returns>
829        explora: function (pintaGrafica, vista, indicador) {
830            var _this = this;
831            if (pintaGrafica === false) {
832                $("#btn_tabla" + _this.id).addClass("active");
833            }
834            //var queVista = (expl_inicia === false ? $("#botonesExpl" + _this.id + " button.active").attr("id") : vista) + _this.id;
835            var queVista = vista + _this.id;
836            switch (queVista) {
837                case "grafica" + _this.id:
838                    {
839                        _this.validaGrafica(pintaGrafica, indicador);
840                    }
841                    break;
842                case "tabla" + _this.id:
843                    {
844                        _this.btnGo("btn_tabla" + _this.id, indicador, event);
845                        _this.registraEvento();
846                    } break;
847                case "metadato" + _this.id:
848                    {
849                        _this.btnGo("btn_metadatoinfo" + _this.id, indicador, event);
850                        _this.registraEvento();
851                    } break;
852                case "comparativo" + _this.id:
853                    {
854                        _this.btnGo("btn_comparativo" + _this.id, indicador, event);
855                        _this.registraEvento();
856                    } break;
857                case "mapa" + _this.id:
858                    {
859                        if (expl_permiteMapa) {
860                            _this.btnGo("btn_mapa" + _this.id, indicador, event);
861                            _this.registraEvento();
862                        }
863                        else
864                            _this.validaGrafica(pintaGrafica, indicador);
865                    } break;
866                default:
867                    {
868                        _this.validaGrafica(pintaGrafica, indicador);
869                    }
870                    break;
871            }
872
873        },
874        validaGrafica: function (pintaGrafica, indicador) {
875            var _this = this;
876            if (pintaGrafica) {
877                _this.btnGo("btn_grafica" + _this.id, indicador, event);
878            }
879            else {
880                expl_itbl = true;
881                document.getElementById("btn_grafica" + _this.id).style.display = "none";
882                $("#btn_tabla" + _this.id).trigger("click");
883
884                document.getElementById("gralDivExpl_" + _this.id).className = "classDiv";
885                document.getElementById("divgral_" + indicador).style.display = "block";
886            }
887        },
888        /// <summary>   Colapsar metadato. </summary>
889        /// <param name="id">   Id del control. </param>
890        /// <returns>   . </returns>
891        collapseMetadato: function (id) {
892            var _this = this;
893            var contenedor = _this.container;
894            var txtMas = (expl_idioma === "es") ? 'Ver más información' : 'Show more information';
895            var txtMenos = (expl_idioma === "es") ? 'Ver menos información' : 'Show less information';
896
897            $('.clp_metadato').slideUp();
898            $('.expandirMD').find('span').removeClass('glyphicon-triangle-top');
899            $('.expandirMD').find('span').addClass('glyphicon-triangle-bottom');
900            $('.expandirMD').find('p').html('<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true" style="margin-right: 5px;"></span>' + txtMas);
901            if (!$('.clp_metadato').is(":visible")) {
902                $('.clp_metadato').slideDown();
903                $('.expandirMD').find('span').removeClass('glyphicon-triangle-bottom');
904                $('.expandirMD').find('span').addClass('glyphicon-triangle-top');
905                $('.expandirMD').find('p').html('<span class="glyphicon glyphicon-triangle-top" aria-hidden="true" style="margin-right: 5px;"></span>' + txtMenos);
906                //exploradorDatos(contenedor).openMetadato('');
907            }
908
909        },
910
911        /// <summary>   Mostrar metadato. </summary>
912        /// <param name="id">   Id del componente. </param>
913        /// <returns>   . </returns>
914        openMetadato: function (id) {
915            //var _this = this;
916            //var contenedor = _this.container;
917        },
918
919        /// <summary>   Cambia la vista principal entre grafica, tabla y metadato </summary>
920        /// <param name="id">   Tipo de vista mostrada. </param>
921        /// <returns>   . </returns>
922        //btnGo: function (id, indicador, event) {
923        //    var _this = this;
924        //    $("#btn_mapa" + _this.id).attr("disabled", false);
925        //    if (id === "btn_grafica" + _this.id) {
926        //        $("#selecAgeoMultiple_" + _this.id).hide();
927        //        $("#selecAgeo_" + _this.id).hide();
928        //    }
929        //    else {
930        //        $("#selecAgeo_" + _this.id).show();
931        //        $("#selecAgeoMultiple_" + _this.id).hide();
932        //    }
933
934        //    //cuando está el combo de multiselección geográfica en la gráfica.
935        //    if (id.indexOf("btn_grafica") !== -1 && expl_selecAgeo) {
936        //        var content = "selecAgeoMultiple_" + _this.id;
937        //        _this.centraTabla(false);
938        //        expl_vistaInicial = "grafica";
939        //        document.getElementById("divTablaExpl" + _this.id) !== null ? document.getElementById("divTablaExpl" + _this.id).style.display = "none" : "";
940        //        document.getElementById("divGraficaExpl" + _this.id).style.display = "inline";
941        //        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
942        //        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
943        //        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
944        //        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
945        //        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
946        //        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
947
948        //        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
949        //        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md menubuttons active";
950        //        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
951        //        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
952        //        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
953
954        //        $("#selecAgeoMultiple_" + _this.id).show();
955
956        //        var seleccion = cmbMultiCheck("#" + content).traeIDseleccion(expl_desglose, expl_indicador);
957        //        if (seleccion !== expl_ageo) {
958        //            cmbMultiCheck("#" + content).checaCombo(expl_ageo, expl_desglose);
959        //        }
960        //        else {
961        //            _this.goGraficaMultiple(indicador);
962        //        }
963
964
965        //        document.getElementById("gralDivExpl_" + _this.id).className = "classDiv";
966        //        document.getElementById("divgral_" + indicador).style.display = "block";
967        //    }
968        //    else {
969        //        //cuando esta el combo select
970        //        if (document.getElementById("selecAgeo_" + _this.id).innerHTML === '') {
971        //            //cuando aún no se pinta el combo select.
972        //            switch (id) {
973        //                case "btn_metadatoinfo" + _this.id:
974        //                    expl_vistaInicial = "metadato";
975        //                    break;
976        //                case "btn_tabla" + _this.id:
977        //                    expl_vistaInicial = "tabla";
978        //                    break;
979        //                case "btn_grafica" + _this.id:
980        //                    expl_vistaInicial = "grafica";
981        //                    break;
982        //                case "btn_comparativo" + _this.id:
983        //                    expl_vistaInicial = "comparativo";
984        //                    break;
985        //                case "btn_mapa" + _this.id:
986        //                    expl_vistaInicial = "mapa";
987        //                    break;
988        //            }
989
990        //            _this.construyeCombosAgeo(expl_ageo, indicador);
991        //        }
992        //        else {
993        //            //checar si ya cambio el valor del área geográfica
994        //            var ageo_select = document.getElementById("combo_enti_" + _this.id).value;
995        //            var trata = expl_ageo.length > 8 ? expl_ageo.substring(0, 8) : expl_ageo;
996        //            if (ageo_select !== trata) {
997        //                //cuando aún no se pinta el combo select.
998        //                switch (id) {
999        //                    case "btn_metadatoinfo" + _this.id:
1000        //                        expl_vistaInicial = "metadato";
1001        //                        break;
1002        //                    case "btn_tabla" + _this.id:
1003        //                        expl_vistaInicial = "tabla";
1004        //                        break;
1005        //                    case "btn_grafica" + _this.id:
1006        //                        expl_vistaInicial = "grafica";
1007        //                        break;
1008        //                    case "btn_comparativo" + _this.id:
1009        //                        expl_vistaInicial = "comparativo";
1010        //                        break;
1011        //                    case "btn_mapa" + _this.id:
1012        //                        expl_vistaInicial = "mapa";
1013        //                        break;
1014        //                }
1015
1016        //                _this.construyeCombosAgeo(expl_ageo, indicador);
1017
1018        //            }
1019        //            else {
1020        //                switch (id) {
1021        //                    case "btn_metadatoinfo" + _this.id:
1022        //                        expl_vistaInicial = "metadato";
1023        //                        _this.centraTabla(false);
1024
1025        //                        if (expl_selecAgeo) {
1026        //                            $("#selecAgeo_" + _this.id).show();
1027        //                        }
1028
1029        //                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
1030        //                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1031        //                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1032        //                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1033        //                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "inline";
1034        //                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1035        //                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1036        //                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1037        //                        //metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie);
1038        //                        metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie, expl_tematica);
1039
1040        //                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md menubuttons";
1041        //                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md ";
1042        //                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1043        //                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1044        //                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md menubuttons active";
1045        //                        // _this.goTabla();
1046        //                        break;
1047        //                    case "btn_tabla" + _this.id:
1048        //                        _this.centraTabla(true);
1049        //                        expl_vistaInicial = "tabla";
1050        //                        document.getElementById("divTablaExpl" + _this.id).style.display = "inline";
1051        //                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1052        //                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1053        //                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1054        //                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1055        //                        //07-04-2020
1056        //                        document.getElementById("divExportarExpl" + _this.id).style.display = "block";
1057        //                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1058        //                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1059        //                        // metadato de exportacion
1060        //                        //metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie);
1061        //                        metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie, expl_tematica);
1062
1063        //                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md menubuttons active";
1064        //                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md";
1065        //                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1066        //                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1067        //                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
1068        //                        _this.goTabla(indicador);
1069        //                        break;
1070        //                    case "btn_grafica" + _this.id:
1071        //                        _this.centraTabla(false);
1072        //                        expl_vistaInicial = "grafica";
1073        //                        document.getElementById("divTablaExpl" + _this.id) !== null ? document.getElementById("divTablaExpl" + _this.id).style.display = "none" : "";
1074        //                        document.getElementById("divGraficaExpl" + _this.id).style.display = "inline";
1075        //                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1076        //                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1077        //                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1078        //                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1079        //                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1080        //                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1081
1082        //                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
1083        //                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md menubuttons active";
1084        //                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1085        //                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1086        //                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
1087
1088        //                        if (expl_selecAgeo) {
1089        //                            $("#selecAgeoMultiple_" + _this.id).show();
1090        //                            _this.goGraficaMultiple(indicador);
1091        //                        }
1092        //                        else {
1093        //                            _this.goGrafica(indicador);
1094        //                        }
1095
1096        //                        break;
1097        //                    case "btn_comparativo" + _this.id:
1098        //                        _this.centraTabla(false);
1099        //                        expl_vistaInicial = "comparativo";
1100        //                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
1101        //                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1102        //                        document.getElementById("divComparativoExpl" + _this.id).style.display = "inline";
1103        //                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1104        //                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1105        //                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1106        //                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1107        //                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1108
1109        //                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
1110        //                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md menubuttons";
1111        //                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1112        //                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md menubuttons active";
1113        //                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
1114
1115        //                        if (expl_esMunicipal) {
1116        //                            _this.pintaGraficaComparativoMunicipal(indicador);
1117        //                        } else {
1118        //                            _this.pintaGraficaComparativo(indicador);
1119        //                        }
1120
1121        //                        break;
1122        //                    case "btn_mapa" + _this.id:
1123        //                        _this.centraTabla(false);
1124        //                        expl_vistaInicial = "mapa";
1125        //                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1126        //                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
1127        //                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1128        //                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1129        //                        document.getElementById("divMapaExpl" + _this.id).style.display = "inline";
1130        //                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1131        //                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1132        //                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1133
1134        //                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1135        //                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
1136        //                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md";
1137        //                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md menubuttons active";
1138        //                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
1139        //                        _this.goMapa(indicador, event);
1140        //                        break;
1141        //                    case "btn_calc" + _this.id:
1142        //                        _this.centraTabla(false);
1143        //                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1144        //                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
1145        //                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1146        //                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1147        //                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1148        //                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1149        //                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1150        //                        document.getElementById("divCalcExpl" + _this.id).style.display = "inline";
1151
1152        //                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
1153        //                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md";
1154        //                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md menubuttons";
1155        //                        BIINEGICalculadoraINP("#divCalcExp" + _this.id).init(indicador, 'ccc', 'ccc', '', '', '', '', 'Mensual', expl_temaPadre);
1156        //                        break;
1157
1158
1159        //                }
1160
1161        //                document.getElementById("gralDivExpl_" + _this.id).className = "classDiv";
1162        //                document.getElementById("divgral_" + indicador).style.display = "block";
1163        //            }
1164        //        }
1165        //    }
1166
1167        //},
1168        traeCheck: function (ageos) {
1169            var areaGeo = ageos.split(",");
1170            var ultimo = areaGeo[areaGeo.length - 1];
1171            /*    return ultimo.length > 8 ? ultimo.substring(0, 8) : ultimo;*/
1172            return ultimo;
1173        },
1174        checaGrafica: function (id, indicador, event) {
1175            var _this = this;
1176            var content = "selecAgeoMultiple_" + _this.id;
1177            var hayPrecision = JSON.parse(document.getElementById("precision_" + _this.id).innerHTML.trim());
1178            var seleccion = "";
1179            if (document.getElementById(content) !== undefined && document.getElementById(content) !== null) {
1180                //seleccion = expl_desglose === "2" ? _this.traeCheck(expl_ageomult) : cmbMultiCheck("#" + content).traeIDseleccion(expl_desglose, expl_indicador);
1181                seleccion = _this.traeCheck(expl_ageomult);
1182            }
1183
1184            /*seleccion = cmbMultiCheck("#" + content).traeIDseleccion(expl_desglose, expl_indicador);*/
1185
1186            //Cuando tiene un desglose diferente de 1, 2 o 3, o cuando no se llamo el componente multiselección
1187            seleccion = seleccion === undefined || seleccion === "" ? (expl_pais === true ? _this.traeCheck(expl_ageomult) :  expl_ageo) : seleccion;
1188            expl_vistaInicial = "grafica";
1189
1190            _this.centraTabla(false);
1191
1192            document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
1193            document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md menubuttons active";
1194            document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1195            document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1196            document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
1197
1198            document.getElementById("divTablaExpl" + _this.id) !== null ? document.getElementById("divTablaExpl" + _this.id).style.display = "none" : "";
1199            document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1200            document.getElementById("divMapaExpl" + _this.id).style.display 
1200= "none";
1201            document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1202            document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1203            document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1204            //document.getElementById("divGraficaExpl" + _this.id).style.display = "inline";
1205            //document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1206
1207
1208
1209
1210            if (seleccion !== expl_ageo) {
1211                if (expl_selecAgeo) {
1212                    if (expl_desglose === "2") {
1213                        expl_ageomult = expl_ageo;
1214                    }
1215
1216                    //12/072024
1217                    if (expl_desglose !== "4") {
1218                        //cmbMultiCheck("#" + content).checaCombo(expl_ageo, expl_desglose, content, expl_indicador);
1219
1220                        //14082024
1221                        alterno_ = _this.id;
1222                        params = {
1223                            "lang": expl_idioma,
1224                            "ageo": expl_ageo,
1225                            "principales": "1",
1226                            "tematica": expl_tematica,
1227                            "localidades": false,
1228                            "indicador": expl_indicador,
1229                            "desglose": parseInt(expl_desglose),
1230                            "dobleUso": true,
1231                            "container": "#" + content
1232                        };
1233
1234                        SitioINEGI_TreeAgeoCheck("#" + content).init(params);
1235
1236                    } else {
1237                        _this.goGrafica(indicador);
1238                        document.getElementById("gralDivExpl_" + _this.id).className = "classDiv";
1239                        document.getElementById("divgral_" + indicador).style.display = "block";
1240
1241                        document.getElementById("divGraficaExpl" + _this.id).style.display = "inline";
1242                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1243                    }
1244                }
1245                else {
1246                    _this.goGrafica(indicador);
1247                    document.getElementById("gralDivExpl_" + _this.id).className = "classDiv";
1248                    document.getElementById("divgral_" + indicador).style.display = "block";
1249                }
1250                //var params = {
1251                //    tematica: expl_tematica,
1252                //    lang: expl_idioma,
1253                //    ageo: expl_ageo,
1254                //    ind: indicador,
1255                //    alterno: _this.id,
1256                //    desglose: expl_desglose
1257                //};
1258                //cmbMultiCheck("#" + content).init(params);
1259            }
1260            else {
1261                document.getElementById("divGraficaExpl" + _this.id).style.display = "inline";
1262                document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1263
1264                //_this.centraTabla(false);
1265                //document.getElementById("divTablaExpl" + _this.id) !== null ? document.getElementById("divTablaExpl" + _this.id).style.display = "none" : "";
1266                //document.getElementById("divGraficaExpl" + _this.id).style.display = "inline";
1267                //document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1268                //document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1269                //document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1270                //document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1271                //document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1272                //document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1273
1274                //document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
1275                //document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md menubuttons active";
1276                //document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1277                //document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1278                //document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
1279
1280                if (expl_selecAgeo) {
1281                    if (hayPrecision) {
1282                        _this.goGrafica(indicador);
1283                    } else {
1284                        if (expl_desglose !== "4") {
1285                            $("#treeageo_" + _this.id).show();
1286                            _this.goGraficaMultiple(indicador);
1287                        } else {
1288                            _this.goGrafica(indicador);
1289                        }
1290                    }
1291                }
1292                else {
1293                    _this.goGrafica(indicador);
1294                }
1295
1296                document.getElementById("gralDivExpl_" + _this.id).className = "classDiv";
1297                document.getElementById("divgral_" + indicador).style.display = "block";
1298            }
1299
1300
1301        },
1302        generaEstructuraTablero: function (id, indicador){
1303            var _this = this;
1304            var id4 = false;
1305            var id5 = false;
1306            var id6 = false;
1307            //Genera estructuras:
1308            var contenedor = document.createElement("div");
1309            contenedor.id = "contenedor-tablero_" + _this.id;
1310            contenedor.className = "container-fluid";
1311
1312            var row1 = document.createElement("div");
1313            row1.className = "row";
1314
1315            var columna1 = document.createElement("div");
1316            columna1.className = "col-xs-12";
1317
1318            var title = document.createElement("label");
1319            title.style.textAlign = "left";
1320            title.style.display = "none";
1321            title.id = "tituloTablero-"+_this.id;
1322            columna1.appendChild(title);
1323
1324            var button = document.createElement("button");
1325            button.type = "button";
1326            button.className = "close";
1327            button.style.opacity = "initial";
1328            button.style.float = "right";
1329            button.id = "btn_zoom-"+_this.id;
1330            button.setAttribute("data-toggle", "tooltip"); 
1331            button.setAttribute("data-original-title", expl_idioma === "es" ? "Expandir" : "Expand"); 
1332            //button.setAttribute("onclick", "javascript:exploradorDatos('" + _this.container + "').tableroCierra()");
1333            button.setAttribute("onclick", "javascript:exploradorDatos('" + _this.container + "').tableroDisplay()");
1334
1335            var spancol1 = document.createElement("span");
1336            spancol1.className = "inegi-extender";
1337            spancol1.id = "spancol1-"+_this.id;
1338            button.appendChild(spancol1);
1339            columna1.appendChild(button);
1340
1341
1342            row1.appendChild(columna1);
1343            contenedor.appendChild(row1);
1344
1345            var row2 = document.createElement("div");
1346            row2.className = "row";
1347            contenedor.appendChild(row2);
1348
1349            //Tabla
1350            var col2 = document.createElement("div");
1351            col2.className = "col-md-6 col-xs-12 espcolumna";
1352            col2.id = "colTabla-"+_this.id;
1353            //col2.style.height = "710px";
1354
1355            var caja2 = document.createElement("div");
1356            caja2.className = "card info-card sales-card";
1357            caja2.id = "tabl_tabla_" + id;
1358
1359            var herr2 = document.createElement("div");
1360            herr2.className = "filter";
1361
1362            var bdy2 = document.createElement("div");
1363            bdy2.className = "card-body";
1364            //bdy2.style.height = "710px";
1365            bdy2.style.maxHeight = "max-content";
1366
1367            var h52 = document.createElement("label");
1368            h52.className = "texto";
1369            h52.style.fontWeight = "bold";
1370            h52.innerText = expl_idioma === "es" ? "Tabla" : "Table";
1371            bdy2.appendChild(h52);
1372
1373            var content2 = document.createElement("div");
1374            content2.className = "classCarga";
1375            content2.id = "tabl_tbl-bdy-"+_this.id;
1376            bdy2.appendChild(content2);
1377
1378            caja2.appendChild(herr2);
1379            caja2.appendChild(bdy2);
1380            col2.appendChild(caja2);
1381            row2.appendChild(col2);
1382
1383            //Mapa
1384            if (expl_permiteMapa) {
1385                id5 = true;
1386
1387                var col5 = document.createElement("div");
1388                col5.className = "col-xs-12 espcolumna";
1389                col5.id = "colMapa-"+_this.id;
1390                col5.style.height = "995px";
1391                col5.style.padding = "0px";
1392
1393                var caja5 = document.createElement("div");
1394                caja5.className = "card info-card sales-card";
1395                caja5.id = "tabl_mapa_" + id;
1396
1397                var herr5 = document.createElement("div");
1398                herr5.className = "filter";
1399
1400                var bdy5 = document.createElement("div");
1401                bdy5.className = "card-body";
1402                bdy5.style.height = "995px";
1403                bdy5.style.maxHeight = "max-content";
1404
1405                /* bdy5.style.overflowY = "auto";*/
1406                bdy5.style.overflowY = "auto";
1407                bdy5.style.padding = "0px";
1408
1409
1410
1411                var h55 = document.createElement("label");
1412                h55.className = "texto";
1413                h55.style.fontWeight = "bold";
1414                h55.innerText = expl_idioma === "es" ? "Mapa" : "Map";
1415                bdy5.appendChild(h55);
1416
1417                var content5 = document.createElement("div");
1418                content5.className = "classCarga";
1419                content5.id = "tabl_mapa-bdy-" + _this.id;
1420                content5.style.margin = "15px";
1421                bdy5.appendChild(content5);
1422
1423                caja5.appendChild(herr5);
1424                caja5.appendChild(bdy5);
1425                col5.appendChild(caja5);
1426                row2.appendChild(col5);
1427            }
1428
1429            ////Metadato
1430            //var col1 = document.createElement("div");
1431            //col1.className = "col-md-6 col-xs-12 espcolumna";
1432
1433            //var caja1 = document.createElement("div");
1434            //caja1.className = "card info-card sales-card";
1435            //caja1.id = "tabl_metadato_" + id;
1436
1437            //var herr1 = document.createElement("div");
1438            //herr1.className = "filter";
1439
1440            //var bdy1 = document.createElement("div");
1441            //bdy1.className = "card-body";
1442            //bdy1.style.height = "100%";
1443            //bdy1.style.maxHeight = "max-content";
1444
1445            //var h51 = document.createElement("label");
1446            //h51.className = "texto";
1447            //h51.innerText = expl_idioma==="es" ? "Metadato": "Metadata";
1448            //bdy1.appendChild(h51);
1449
1450            //var content1 = document.createElement("div");
1451            ////content1.className = "d-flex";
1452            //content1.id = "tabl_met-bdy";
1453            //bdy1.appendChild(content1);
1454
1455            //caja1.appendChild(herr1);
1456            //caja1.appendChild(bdy1);
1457            //col1.appendChild(caja1);
1458            //row2.appendChild(col1);
1459
1460            //Gráfica
1461            var col3 = document.createElement("div");
1462            col3.className = "col-md-6 col-xs-12 espcolumna";
1463            col3.id = "colGrafica-"+_this.id;
1464
1465            var caja3 = document.createElement("div");
1466            caja3.className = "card info-card sales-card";
1467            caja3.id = "tabl_grafica_" + id;
1468
1469            var herr3 = document.createElement("div");
1470            herr3.className = "filter";
1471
1472            var bdy3 = document.createElement("div");
1473            bdy3.className = "card-body";
1474
1475            var h53 = document.createElement("label");
1476            h53.className = "texto";
1477            h53.style.fontWeight = "bold";
1478            h53.innerText = expl_idioma === "es" ? "Gráfica" : "Chart";
1479            bdy3.appendChild(h53);
1480
1481            var content3 = document.createElement("div");
1482            content3.className = "classCarga";
1483            content3.id = "tabl_gra-bdy-"+_this.id;
1484            bdy3.appendChild(content3);
1485
1486            caja3.appendChild(herr3);
1487            caja3.appendChild(bdy3);
1488            col3.appendChild(caja3);
1489            row2.appendChild(col3);
1490
1491            //Comparativo
1492            var display = _this.validaComparativo();
1493            if (display !== "none") {
1494                id4 = true;
1495                var col4 = document.createElement("div");
1496                col4.className = "col-md-6 col-xs-12 espcolumna";
1497
1498                var caja4 = document.createElement("div");
1499                caja4.className = "card info-card sales-card";
1500                caja4.id = "tabl_compara_" + id;
1501
1502                var herr4 = document.createElement("div");
1503                herr4.className = "filter";
1504
1505                var bdy4 = document.createElement("div");
1506                bdy4.className = "card-body";
1507
1508                var h54 = document.createElement("label");
1509                h54.className = "texto";
1510                h54.style.fontWeight = "bold";
1511                h54.innerText = expl_idioma === "es" ? "Comparativo" : "Comparative";
1512                bdy4.appendChild(h54);
1513
1514                var content4 = document.createElement("div");
1515                content4.className = "classCarga";
1516                content4.id = "tabl_comp-bdy-"+_this.id;
1517                bdy4.appendChild(content4);
1518
1519                caja4.appendChild(herr4);
1520                caja4.appendChild(bdy4);
1521                col4.appendChild(caja4);
1522                row2.appendChild(col4);
1523            }
1524
1525            //Calculadora
1526            //if (expl_temaPadre !== undefined)
1527            //    if (expl_temaPadre.substring(0, 4) === "1120") {
1528            //        id6 = true;
1529
1530            //        var col6 = document.createElement("div");
1531            //        col6.className = "col-lg-6 col-md-6 col-xs-12";
1532
1533            //        var caja6 = document.createElement("div");
1534            //        caja6.className = "card info-card sales-card";
1535            //        caja6.id = "tabl_calculadora_" + id;
1536
1537            //        var herr6 = document.createElement("div");
1538            //        herr6.className = "filter";
1539
1540            //        var bdy6 = document.createElement("div");
1541            //        bdy6.className = "card-body";
1542
1543            //        var h56 = document.createElement("label");
1544            //        h56.className = "texto";
1545            //        h56.innerText = expl_idioma === "es" ? "Calculadora": "Calculator";
1546            //        bdy6.appendChild(h56);
1547
1548            //        var content6 = document.createElement("div");
1549            //        //content6.className = "d-flex";
1550            //        content6.id = "tabl_calc-bdy";
1551            //        bdy6.appendChild(content6);
1552
1553            //        caja6.appendChild(herr6);
1554            //        caja6.appendChild(bdy6);
1555            //        col6.appendChild(caja6);
1556            //        row2.appendChild(col6);
1557
1558            //    }
1559
1560            document.getElementById("divTableroComp" + _this.id).appendChild(contenedor);
1561            setTimeout(function () {
1562                //LLamaComponentes:
1563                _this.llamaComponentes(id, indicador, id4, id5, id6);
1564            }, 1500);
1565        },
1566        btnTablero: function (id, indicador, event) {
1567            var _this = this;
1568          /*  _this.tableroGo();*/
1569            if (document.getElementById("divTableroComp" + _this.id).innerHTML !== ""){
1570                $("#divTableroComp" + _this.id).contents().remove();
1571            }
1572            $("#treeageo_" + _this.id).hide();
1573            $("#selecAgeo_" + _this.id).hide();
1574
1575            _this.btnsTablero();
1576            _this.generaEstructuraTablero(id, indicador);
1577        },
1578        llamaComponentes: function (id, indicador, id4, id5, id6) {
1579            var _this = this;
1580            var title = document.getElementById("titletablero_" + _this.id).innerText;
1581            var hayPrecision = JSON.parse(document.getElementById("precision_" + _this.id).innerHTML.trim());
1582
1583            expl_ageo = expl_ageo === "0" ? "00" : expl_ageo;
1584            expl_ageomult = this.trataCvesMulti(expl_ageomult);
1585
1586            //Metadato
1587            //metadatoControlV3("#tabl_met-bdy").init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie, expl_tematica);
1588
1589            //Tabla
1590            var cobertura = expl_ageo.toString();
1591            var tabla = new CuadroComponente();
1592            var datos =
1593            {
1594                ind: indicador.toString(),
1595                ag: cobertura.toString() === "0" ? "00" : cobertura.toString(),
1596                tc: "8",
1597                mf: "false",
1598                mn: "false",
1599                mu: "true",
1600                ec: "2",
1601                ord: "pd",
1602                mse: "true",
1603                lang: expl_idioma,
1604                mce: "true",
1605                tematica: expl_tematica,
1606                callback: function () {
1607                    $("#tabl_tbl-bdy-" + _this.id).removeClass("classCarga");
1608                    setTimeout(function () {
1609                        //Resize contenedores
1610                        var altoTabla = $("#colTabla-"+_this.id).height();
1611                        if (altoTabla < 710) {
1612                            //$("#colMapa-" + _this.id).height(950);
1613                            $("#colMapa-" + _this.id).height(995);
1614                        }
1615                        else {
1616                         /*   $("#colMapa-" + _this.id).height(altoTabla);*/
1617                        }
1618
1619                        //Mapa
1620                        if (id5) {
1621                            $("#colMapa-" + _this.id).height("auto");
1622                            var url = _this.servicio + '/API.svc/MetadatoIndicador/' + expl_idioma + '/' + indicador.toString() + '/0/null/null/null/' + expl_tematica + '/json/' + _this.tk + '?callback=?';
1623                            $.getJSON(url, null, function (data) {
1624                                if (title === "") {
1625                                    title = data.NOMBRE_INDICADOR + (data.NOMBRE_UNIDAD !== "" && data.NOMBRE_UNIDAD !== null ? " (" + data.NOMBRE_UNIDAD + ")" : "");
1626                                }
1627                                var listaTodasLasCifras = data.CIFRAS_ESTATUS;
1628                                var ultPeriodo = listaTodasLasCifras.length > 0 ? listaTodasLasCifras[listaTodasLasCifras.length - 1].periodos : document.getElementById("up_" + _this.id).innerText;
1629
1630                                var parametrosD3 = {};
1631                                var fuenteAdicional = [{ "nombreF": "Fuente adicional", url: "https://www.inegi.org.mx" }];
1632                                parametrosD3.id = 'tabl_mapa-bdy-'+_this.id;
1633                                parametrosD3.indica = indicador;
1634
1635                                if (expl_desglose === "3") {
1636                                    parametrosD3.ageo = expl_ageo === "00" || expl_ageo==="0" ? "00" :  _this.obtieneClaveAgeo("municipal");
1637                                    parametrosD3.cobertura = "mun";
1638                                } else {
1639                                    //área geográfica nacional para desplegar el mapa.
1640                                    parametrosD3.ageo = "00";
1641                                }
1642
1643                                //parametrosD3.ageo = "00";
1644                                parametrosD3.pf = ultPeriodo
1645                                parametrosD3.muv = true;
1646                                parametrosD3.mum = true;
1647                                parametrosD3.mf = true;
1648                                parametrosD3.fadd = fuenteAdicional;
1649                                parametrosD3.tm = expl_tematica;
1650                                parametrosD3.herramienta = _this.takeHerramienta(expl_tematica);
1651                                parametrosD3.mestra = true
1652                                parametrosD3.estra = "1";
1653                                parametrosD3.ordenEstrato = "asc";
1654                                parametrosD3.mup = true;
1655                                parametrosD3.mpaleta = true;
1656                                crearMapaTematicoD3(parametrosD3);
1657                            });
1658                        }
1659                        $("#tabl_mapa-bdy-" + _this.id).removeClass("classCarga");
1660                        setTimeout(function () {
1661                        //Gráfica
1662                        if (id4 === false) {
1663                            //si no hay comparativo, poner en todo el ancho la gráfica
1664                            $("#colGrafica-"+_this.id).removeClass().addClass("col-xs-12 espcolumna");
1665                        }
1666
1667                        var datosG = {};
1668                        var grafica = new GeneraGrafica();
1669
1670                        datosG.ind = indicador;
1671                        datosG.mn = "false";
1672                        datosG.mf = "false";
1673                        datosG.cbs = "false";
1674                        datosG.mu = "true";
1675                        datosG.dop = 1;
1676                        datosG.mfpu = "rango";
1677                        datosG.lang = expl_idioma;
1678                        datosG.tematica = expl_tematica;
1679                        if (expl_colorGlobal !== "") {
1680                            datosG.cls = expl_colorGlobal;
1681                        }
1682
1683                        //Multiárea geográfica
1684                            if (expl_selecAgeo) {
1685                                if (hayPrecision === true) {
1686                                    datosG.tg = "Barra.B";
1687                                    datosG.eb = "true";
1688                                    datosG.tc = "precision";
1689                                }
1690                                else {
1691                                    if (window.location.href.indexOf("/app/indicesdeprecios/Estructura.aspx") !== -1) {
1692                                        datosG.export = false;
1693                                    } else {
1694                                        datosG.export = true;
1695                                    }
1696
1697                                    datosG.ag = expl_ageomult;
1698                                    datosG.tg = "Linea.L";
1699
1700                                    if (expl_ageomult.split(',').length >= 2) {
1701                                        datosG.switch = false;
1702                                    } else {
1703                                        datosG.switch = true;
1704                                    }
1705                                }
1706                            }
1707                            else {
1708                                datosG.tg = _this.buscaTipoGrafica(indicador, expl_ageo, "Linea");
1709                                datosG.ix = expl_escala.toString();
1710                                var areaFormateada = "";
1711                                if (expl_ageo === "*" || expl_ageo === "'")
1712                                    areaFormateada = expl_ageo.substring(1, expl_ageo.length - 1);
1713                                else
1714                                    areaFormateada = expl_ageo;
1715
1716                                datosG.ag = areaFormateada;
1717
1718                                if (hayPrecision === true) {
1719                                    datosG.tg = "Barra.B";
1720                                    datosG.eb = "true";
1721                                    datosG.tc = "precision";
1722                                }
1723                                else {
1724                                    if (window.location.href.indexOf("/app/indicesdeprecios/Estructura.aspx") !== -1) {
1725                                        datosG.export = false;
1726                                    } else {
1727                                        datosG.export = true;
1728                                    }
1729                                    datosG.switch = true;
1730                                }
1731                            }
1732                            
1733
1734                            datosG.callback = function () {
1735                                $("#tabl_gra-bdy-" + _this.id).removeClass("classCarga");
1736                                //Comparativo
1737                                if (id4) {
1738                                    if (expl_esMunicipal) {
1739                                        if (municipios.length === 0) {
1740                                            var ageotemp = expl_ageo;
1741                                            //if (expl_ageo.length > 8) {
1742                                            //ageotemp = ageoinicial.substring(6, 8)};
1743          
1744
1745                                            //var ageotemp = expl_ageoCmb.substring(6, 8);
1746                                            var ruta = _this.servicio + '/API.svc/CatalogoAreaGeograficaV3/' + ageotemp + '/' + indicador + '/null/null/' + expl_tematica + '/1/json/' + _this.tk + '?callback=?';
1747                                            $.getJSON(ruta, null, function (data) {
1748                                                var Lmunicipios = data[0].AREAS_GEOGRAFICAS_DEPENDIENTES;
1749                                                for (var ag = 0; ag < Lmunicipios.length; ag++) {
1750                                                    municipios.push(Lmunicipios[ag].AREA_GEOGRAFICA);
1751                                                    /*_this.tableroComparativo(municipios, indicador);*/
1752                                                }
1753                                                _this.tableroComparativo(municipios, indicador);
1754                                            });
1755                                        }
1756                                        else {
1757                                            _this.tableroComparativo(municipios, indicador);
1758                                        }
1759                                    }
1760                                    else {
1761                                        _this.tableroComparativo(municipios, indicador);
1762                                    }
1763                                }
1764                            };
1765
1766                            grafica.CargaParametros("tabl_gra-bdy-" + _this.id, datosG);
1767                        }, 1500);
1768
1769                    }, 1500);
1770                }
1771            };
1772            if (hayPrecision === true) {
1773                datos.tc = "precision";
1774                datos.eb = "true";
1775                datos.idtema = 12;
1776            }
1777            tabla.GeneraCuadro(datos, "tabl_tbl-bdy-"+_this.id);
1778
1779            if (title === "") {
1780                var urltitle = _this.servicio + '/API.svc/MetadatoIndicador/' + expl_idioma + '/' + indicador + '/null/null/null/null/' + expl_tematica + '/json/' + _this.tk + '?callback=?';
1781                $.getJSON(urltitle, null, function (data) {
1782                    title = data.NOMBRE_INDICADOR + (data.NOMBRE_UNIDAD !== "" && data.NOMBRE_UNIDAD !== null ? " (" + data.NOMBRE_UNIDAD + ")" : "");
1783                    document.getElementById("tituloTablero-"+_this.id).innerText = title;
1784                });
1785            }
1786            else {
1787                document.getElementById("tituloTablero-"+_this.id).innerText = title;
1788            }
1789        },
1790        tableroComparativo: function (Lmunicipios, indicador) {
1791            var _this = this;
1792            var graficaComparativo = new GeneraGrafica();
1793            var datosComparativo = {};
1794            datosComparativo.tg = "Barra.A";
1795            datosComparativo.mn = "false";
1796            datosComparativo.mf = "false";
1797            datosComparativo.cbs = "false";
1798            datosComparativo.mu = "true";
1799            datosComparativo.dop = 1;
1800            datosComparativo.ord = "n";
1801            datosComparativo.ox = "h";
1802            datosComparativo.o = "h";
1803            datosComparativo.lang = expl_idioma;
1804            datosComparativo.tematica = expl_tematica;
1805            datosComparativo.ind = indicador.toString();
1806
1807            if (expl_colorGlobal !== "") {
1808                datosComparativo.cls = expl_colorGlobal;
1809            }
1810
1811            if (expl_esMunicipal) {
1812                datosComparativo.pagcat = "true";
1813                datosComparativo.ag = Lmunicipios.join(",");
1814            } else {
1815               
1816                if (datosComparativo.ind.length < 10)
1817                    //datosComparativo.ag = "00";
1818                    datosComparativo.ag = "0";
1819                else
1820                    datosComparativo.ag = "entidades";
1821
1822
1823                if (expl_pais === true) {
1824                    if (array_pais.length > 0) {
1825                        datosComparativo.ag = array_pais.join(",");
1826                    }
1827                    else {
1828                        datosComparativo.ag = "entidades";
1829                    }
1830                }
1831            }
1832            graficaComparativo.CargaParametros("tabl_comp-bdy-" + _this.id, datosComparativo);
1833            $("#tabl_comp-bdy-" + _this.id).removeClass("classCarga");
1834        },
1835        btnsTablero: function () {
1836            var _this = this;
1837            document.getElementById("divTablaExpl" + _this.id).style.display = "none";
1838            document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1839            document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1840            document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1841            document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1842            document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1843            document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1844            document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1845            document.getElementById("divTableroExpl" + _this.id).style.display = "inline";
1846
1847            document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md menubuttons";
1848            document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md ";
1849            document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1850            document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1851            document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
1852            document.getElementById("btn_tablero" + _this.id).className = "btn btn-default btn-md menubuttons active";
1853
1854        },
1855        tableroDisplay: function () {
1856            var _this = this;
1857            var span = document.getElementById("spancol1-"+_this.id).className;
1858            if (span === "inegi-extender") {
1859                _this.tableroGo();
1860
1861            } else {
1862                _this.tableroCierra();
1863            }
1864        },
1865        tableroCierra: function () {
1866            var _this = this;
1867            var tablero = document.getElementById("spancol1-"+_this.id).className;
1868
1869            if (tablero === "inegi-estrechar") {
1870                $("body").removeClass("quitaScroll");
1871                $("#divTableroComp" + _this.id).removeClass();
1872                $("#spancol1-"+_this.id).removeClass("inegi-estrechar").addClass("inegi-extender");
1873                $("#btn_zoom-"+_this.id).attr("data-original-title", expl_idioma === "es" ? "Expandir" : "Expand");
1874                $("#tituloTablero-"+_this.id).hide();
1875
1876                setTimeout(function () {
1877                    //Resize contenedores
1878                    var altoTabla = $("#colTabla-"+_this.id).height();
1879                    if (altoTabla < 710) {
1880                        //$("#colMapa-" + _this.id).height(950);
1881                        $("#colMapa-" + _this.id).height(995);
1882                    } else {
1883                      /*  $("#colMapa-"+_this.id).height(altoTabla);*/
1884                    }
1885                }, 1500);
1886
1887            }
1888            else {
1889                _this.tableroGo();
1890            }
1891            
1892        },
1893        tableroGo_respaldo: function () {
1894            var _this = this;
1895            $("#divTableroComp" + _this.id).addClass("allPantalla");
1896            $("body").addClass("quitaScroll");
1897            $("#spancol1-"+_this.id).removeClass("inegi-extender").addClass("inegi-estrechar");
1898            $("#btn_zoom-"+_this.id).attr("data-original-title", expl_idioma === "es" ? "Reducir" : "Reduce");
1899            $("#tituloTablero-"+_this.id).show();
1900
1901            setTimeout(function () {
1902                //Resize contenedores
1903                var altoTabla = $("#colTabla-"+_this.id).height();
1904                if (altoTabla < 710) {
1905                    //$("#colMapa-" + _this.id).height(950);
1906                    $("#colMapa-" + _this.id).height(995);
1907                } else {
1908                 /*   $("#colMapa-"+_this.id).height(altoTabla);*/
1909                }
1910            }, 1500);
1911        },
1912        tableroGo: function () {
1913            var _this = this;
1914            $("#divTableroComp" + _this.id).addClass("allPantalla");
1915            $("body").addClass("quitaScroll");
1916            $("#spancol1-"+_this.id).removeClass("inegi-extender").addClass("inegi-estrechar");
1917            $("#btn_zoom-"+_this.id).attr("data-original-title", expl_idioma === "es" ? "Reducir" : "Reduce");
1918            $("#tituloTablero-"+_this.id).show();
1919
1920            setTimeout(function () {
1921                //Resize contenedores
1922                var altoTabla = $("#colTabla-"+_this.id).height();
1923                if (altoTabla < 710) {
1924                    //$("#colMapa-" + _this.id).height(950);
1925                    $("#colMapa-" + _this.id).height(995);
1926                } else {
1927               /*     $("#colMapa-"+_this.id).height(altoTabla);*/
1928                }
1929            }, 1500);
1930        },
1931        btnGo: function (id, indicador, event) {
1932            var _this = this;
1933            var hayPrecision = JSON.parse(document.getElementById("precision_" + _this.id).innerHTML.trim());
1934
1935            $("#btn_mapa" + _this.id).attr("disabled", false);
1936            if (id === "btn_grafica" + _this.id) {
1937                document.getElementById("divTableroExpl" + _this.id).style.display = "none";
1938                $("#treeageo_" + _this.id).hide();
1939
1940                //12072024
1941                if (expl_desglose !== "4") {
1942                    if (!hayPrecision) {
1943                        $("#selecAgeo_" + _this.id).hide();
1944                    }
1945                }
1946
1947                _this.checaGrafica(id, indicador, event);
1948            }
1949            else {
1950                $("#selecAgeo_" + _this.id).show();
1951                $("#treeageo_" + _this.id).hide();
1952
1953                switch (id) {
1954                    case "btn_metadatoinfo" + _this.id:
1955                        expl_vistaInicial = "metadato";
1956                        _this.centraTabla(false);
1957
1958                        if (expl_selecAgeo) {
1959                            $("#selecAgeo_" + _this.id).show();
1960                        }
1961
1962                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
1963                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1964                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1965                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1966                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "inline";
1967                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1968                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
1969                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1970                        document.getElementById("divTableroExpl" + _this.id).style.display = "none";
1971                        //metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie);
1972                        metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie, expl_tematica);
1973
1974                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md menubuttons";
1975                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md ";
1976                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
1977                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
1978                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md menubuttons active";
1979                        document.getElementById("btn_tablero" + _this.id).className = "btn btn-default btn-md";
1980                        // _this.goTabla();
1981                        break;
1982                    case "btn_tabla" + _this.id:
1983                        _this.centraTabla(true);
1984                        expl_vistaInicial = "tabla";
1985                        document.getElementById("divTablaExpl" + _this.id).style.display = "inline";
1986                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
1987                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
1988                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
1989                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
1990                        //07-04-2020
1991                        document.getElementById("divExportarExpl" + _this.id).style.display = "block";
1992                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
1993                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
1994                        document.getElementById("divTableroExpl" + _this.id).style.display = "none";
1995                        // metadato de exportacion
1996                        //metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie);
1997                        metadatoControlV3("#divMetadatoExpl" + _this.id).init(expl_ageo.toString(), indicador, 0, expl_idioma, false, expl_bie, expl_tematica);
1998
1999                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md menubuttons active";
2000                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md";
2001                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
2002                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
2003                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
2004                        document.getElementById("btn_tablero" + _this.id).className = "btn btn-default btn-md";
2005
2006                        _this.goTabla(indicador);
2007                        break;
2008                    case "btn_comparativo" + _this.id:
2009                        _this.centraTabla(false);
2010                        expl_vistaInicial = "comparativo";
2011                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
2012                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
2013                        document.getElementById("divComparativoExpl" + _this.id).style.display = "inline";
2014                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
2015                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
2016                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
2017                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
2018                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
2019                        document.getElementById("divTableroExpl" + _this.id).style.display = "none";
2020
2021                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
2022                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md menubuttons";
2023                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md";
2024                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md menubuttons active";
2025                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
2026                        document.getElementById("btn_tablero" + _this.id).className = "btn btn-default btn-md";
2027
2028                        if (expl_esMunicipal) {
2029                            _this.pintaGraficaComparativoMunicipal(indicador);
2030                        } else {
2031                            _this.pintaGraficaComparativo(indicador);
2032                        }
2033
2034                        break;
2035                    case "btn_mapa" + _this.id:
2036                        _this.centraTabla(false);
2037                        expl_vistaInicial = "mapa";
2038                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
2039                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
2040                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
2041                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
2042                        document.getElementById("divMapaExpl" + _this.id).style.display = "inline";
2043                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
2044                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
2045                        document.getElementById("divCalcExpl" + _this.id).style.display = "none";
2046                        document.getElementById("divTableroExpl" + _this.id).style.display = "none";
2047
2048                        document.getElementById("btn_comparativo" + _this.id).className = "btn btn-default btn-md";
2049                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
2050                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md";
2051                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md menubuttons active";
2052                        document.getElementById("btn_metadatoinfo" + _this.id).className = "btn btn-default btn-md";
2053                        document.getElementById("btn_tablero" + _this.id).className = "btn btn-default btn-md";
2054
2055                        _this.goMapa(indicador, event);
2056                        break;
2057                    case "btn_calc" + _this.id:
2058                        _this.centraTabla(false);
2059                        document.getElementById("r_metadatoExpl" + _this.id).style.display = "none";
2060                        document.getElementById("divTablaExpl" + _this.id).style.display = "none";
2061                        document.getElementById("divComparativoExpl" + _this.id).style.display = "none";
2062                        document.getElementById("divGraficaExpl" + _this.id).style.display = "none";
2063                        document.getElementById("divMapaExpl" + _this.id).style.display = "none";
2064                        document.getElementById("botonesExpl" + _this.id).style.display = "inline";
2065                        document.getElementById("divExportarExpl" + _this.id).style.display = "none";
2066                        document.getElementById("divCalcExpl" + _this.id).style.display = "inline";
2067                        document.getElementById("divTableroExpl" + _this.id).style.display = "none";
2068
2069                        document.getElementById("btn_tabla" + _this.id).className = "btn btn-default btn-md";
2070                        document.getElementById("btn_grafica" + _this.id).className = "btn btn-default btn-md";
2071                        document.getElementById("btn_mapa" + _this.id).className = "btn btn-default btn-md menubuttons";
2072                        document.getElementById("btn_tablero" + _this.id).className = "btn btn-default btn-md";
2073                        BIINEGICalculadoraINP("#divCalcExp" + _this.id).init(indicador, 'ccc', 'ccc', '', '', '', '', 'Mensual', expl_temaPadre);
2074                        break;
2075                }
2076
2077                document.getElementById("gralDivExpl_" + _this.id).className = "classDiv";
2078                document.getElementById("divgral_" + indicador).style.display = "block";
2079            }
2080        },
2081        centraTabla: function (verCentrado) {
2082            var _this = this;
2083            //var centradoBoot = "col-md-offset-5 col-sm-offset-3 col-xs-offset-1";
2084            var centradoBoot = "center-table";
2085            if (document.getElementById("divT" + _this.id) !== null) {
2086                var claseDiv = document.getElementById("divT" + _this.id).className;
2087                if (verCentrado) {
2088                    if (claseDiv.indexOf(centradoBoot) === -1)
2089                        document.getElementById("divT" + _this.id).className = claseDiv += centradoBoot;
2090                }
2091
2092                else {
2093                    document.getElementById("divT" + _this.id).className = claseDiv.replace(centradoBoot, "");
2094                }
2095            }
2096        },
2097
2098        /// <summary>   Muestra tabla de valores por periodos. </summary>
2099        /// <returns>   . </returns>
2100        goTabla: function (indicador) {
2101            var _this = this;
2102
2103            if (expl_selecAgeo) {
2104                $("#selecAgeo_" + _this.id).show();
2105            }
2106
2107            $("#btn_tabla" + _this.id).attr("disabled", "disabled");
2108            if (document.getElementById("titulo_per" + _this.id) !== null) {
2109                document.getElementById("titulo_per" + _this.id).style.display = "none";
2110            }
2111
2112
2113            if (indicador.length > 0 && expl_ageo.length > 0) {
2114                //var cobertura = _this.rellenaAgeo(expl_ageo.toString())
2115                var cobertura = expl_ageo.toString();
2116                var contenido = document.getElementById("divT" + _this.id).innerHTML = "";
2117                var cuadro = new CuadroComponente();
2118                var datos =
2119                {
2120                    ind: indicador.toString(),
2121                    ag: cobertura.toString() === "0" ? "00" : cobertura.toString(),
2122                    tc: "8",
2123                    mf: "false",
2124                    mn: "false",
2125                    mu: "true",
2126                    ec: "2",
2127                    ord: "pd",
2128                    mse: "true",
2129                    lang: expl_idioma,
2130                    mce: "true",
2131                    tematica: expl_tematica,
2132                    callback: function () {
2133                        $("#btn_tabla" + _this.id).attr("disabled", false);
2134                    }
2135                };
2136                var hayPrecision = JSON.parse(document.getElementById("precision_" + _this.id).innerHTML.trim());
2137                if (hayPrecision === true) {
2138                    datos.tc = "precision";
2139                    datos.eb = "true";
2140                    datos.idtema = 12;
2141                }
2142                cuadro.GeneraCuadro(datos, "divT" + _this.id);
2143            }
2144            //setTimeout(function () {
2145            //    //AMCR-07042020S
2146            //    document.getElementById("divExportarExpl" + _this.id).style.display = "block";
2147            //}, 4000);
2148
2149            if (expl_itbl) {
2150                var contenedor = document.getElementById("divT" + _this.id);
2151                if (contenedor !== null) {
2152
2153                    _this.registraEvento();
2154                    expl_itbl = false;
2155                }
2156            }
2157        },
2158
2159        /// <summary>   Muestra componente de grafica. </summary>
2160        /// <returns>   . </returns>
2161        goGrafica: function (indicador) {
2162            var _this = this;
2163
2164            if (expl_selecAgeo) {
2165                $("#selecAgeo_" + _this.id).show();
2166            }
2167
2168            $("#btn_grafica" + _this.id).attr("disabled", "disabled");
2169            if (document.getElementById("titulo_per" + _this.id) !== null) {
2170                document.getElementById("titulo_per" + _this.id).style.display = "none";
2171            }
2172            var cobertura = expl_ageo.toString();
2173
2174            //var cobertura = _this.rellenaAgeo(expl_ageo.toString());
2175            //_this.goPinta(indicador, cobertura);
2176            _this.consultaFrecuencia(indicador, cobertura, false);
2177        },
2178
2179        /// <summary>   Muestra componente de grafica con selección múltiple. </summary>
2180        /// <returns>   . </returns>
2181        goGraficaMultiple: function (indicador) {
2182            var _this = this;
2183
2184            //Oculta combos de seleccción de área geográfica en una
2185            $("#selecAgeo_" + _this.id).hide();
2186
2187            $("#btn_grafica" + _this.id).attr("disabled", "disabled");
2188            if (document.getElementById("titulo_per" + _this.id) !== null) {
2189                document.getElementById("titulo_per" + _this.id).style.display = "none";
2190            }
2191
2192            /*            _this.consultaFrecuencia(indicador, expl_ageomult,true);*/
2193            _this.pintaGraficaMultiple();
2194
2195        },
2196        trataCvesMulti: function (ageo) {
2197            var arrai = [];
2198            var vec = ageo.split(",");
2199            var result = "";
2200            for (var i = 0; i < vec.length; i++) {
2201                if (vec[i] !== "") {
2202                    if (vec[i] === "0") {
2203                        arrai.push("00");
2204                    } else {
2205                        arrai.push(vec[i]);
2206                    }
2207                }
2208            }
2209            result = arrai.join(",");
2210            return result;
2211        },
2212        pintaGraficaMultiple: function (escalaPeriodos) {
2213            var _this = this;
2214            expl_ageomult = this.trataCvesMulti(expl_ageomult);
2215
2216
2217            var datos = {};
2218            datos.ind = expl_indicador;
2219            datos.ag = expl_ageomult;
2220            /*datos.ag = expl_ageo;*/
2221            datos.tg = "Linea.L";
2222            datos.mn = "false";
2223            datos.mf = "false";
2224            datos.cbs = "false";
2225            datos.mu = "true";
2226            datos.lang = expl_idioma;
2227            datos.dop = 1;
2228            datos.mfpu = "rango";
2229
2230            if (expl_colorGlobal !== "") {
2231                datos.cls = expl_colorGlobal;
2232            }
2233            /*datos.ix = escalaPeriodos.toString();*/
2234
2235
2236
2237            if (_this.servicio.toUpperCase().indexOf("V1_2") !== -1 || _this.servicio.toUpperCase().indexOf("V1_3") !== -1) {
2238                var tematica = (document.getElementById("help_" + _this.id).innerHTML.trim()).split("_")[1];
2239                datos.tematica = tematica;
2240            }
2241            var hayPrecision = JSON.parse(document.getElementById("precision_" + _this.id).innerHTML.trim());
2242            if (hayPrecision === true) {
2243                datos.tg = "Barra.B";
2244                datos.eb = "true";
2245                datos.tc = "precision";
2246            }
2247            else {
2248                if (window.location.href.indexOf("/app/indicesdeprecios/Estructura.aspx") !== -1) {
2249                    datos.export = false;
2250                } else {
2251                    datos.export = true;
2252                }
2253
2254
2255                if (expl_ageomult.split(',').length >= 2) {
2256                    datos.switch = false;
2257                } else {
2258                    datos.switch = true;
2259                }
2260
2261
2262            }
2263
2264            datos.callback = function () {
2265                $("#btn_grafica" + _this.id).attr("disabled", false);
2266            };
2267
2268            var graficaMultiple = new GeneraGrafica();
2269            graficaMultiple.CargaParametros("divGraficaExpl" + _this.id, datos);
2270
2271            var contenedor = document.getElementById("containerdivGraficaExpl" + _this.id);
2272            if (contenedor !== null) {
2273                _this.registraEvento();
2274            }
2275        },
2276
2277        /// <summary>   Muestra componente de mapa </summary>
2278        /// <returns>   . </returns>
2279        goMapa: function (indicador, event) {
2280            var _this = this;
2281            if (indicador.length > 0 && expl_ageo.length > 0 && expl_uanio.length > 0) {
2282
2283                //28/072023
2284                //En llamada con Sergio Nieto y Claudia se comento en quitar el combo de selección múltiple
2285                // de área geográficas en el mapa
2286                $("#selecAgeo_" + _this.id).hide();
2287
2288                //24/04/2025
2289                //Se agrega combo de mapa, ya que si existe mapa estatal por municipios
2290                //$("#selecAgeo_" + _this.id).show();
2291
2292
2293                $("#btn_mapa" + _this.id).attr("disabled", "disabled");
2294                $("#componenteMapa" + this.id).contents().remove();
2295                $("#componenteMapa" + this.id).html();
2296
2297
2298                //var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox/') > -1;
2299                //var is_netscape = navigator.userAgent.toLowerCase().indexOf('netscape/') > -1;
2300
2301                //if (is_firefox || is_netscape) {
2302                //    event.cancelBubble = true;
2303                //    event.stopImmediatePropagation();
2304                //    event.stopPropagation();
2305                //    if (event.cancelable) {
2306                //        event.preventDefault();
2307                //    }
2308                //}
2309                //else {
2310                //    window.event.cancelBubble = true;
2311                //    window.event.returnValue = false;
2312                //}
2313
2314                //setTimeout(function () {
2315                //    $("#btn_mapa" + _this.id).attr("disabled", false);
2316                //}, 3000);
2317
2318                setSizesMapa();
2319                if (document.getElementById("titulo_per" + _this.id) !== null) {
2320                    document.getElementById("titulo_per" + _this.id).style.display = "none";
2321                }
2322
2323                //crearMapaTematico('componenteMapa' + _this.id, indicador, _this.obtieneClaveNacional("municipal"), '1');
2324                //crearMapaTematico('componenteMapa' + _this.id, indicador, _this.obtieneClaveAgeo("municipal"), '2');
2325                _this.nuevollamadoMapa(indicador);
2326                _this.setSizeMCMapa();
2327            }
2328        },
2329        checaPeriodoV2: function (indicador) {
2330            var _this = this;
2331            var ultPeriodo;
2332            //var ageoinicial = document.getElementById("agr_" + _this.id).innerText.trim();
2333
2334            //28/07/2023
2335            //En llamada con Claudia y Sergio Nieto se me comento que siempre se debe enviar el
2336            // área geográfica nacional para desplegar el mapa.
2337
2338            //23/04/2025
2339            //Por correo Claudia me pidio agregar mapa por entidad cuando el m
2339áximo desglose del indicador sea 3 
2340            //y diferente del nacional
2341
2342            var ageoinicial = "0";
2343            var url = _this.servicio.toUpperCase().indexOf("V1_2") != -1 || _this.servicio.toUpperCase().indexOf("V1_3") != -1 ? (_this.servicio + '/API.svc/MetadatoIndicador/' + expl_idioma + '/' + indicador + '/' + ageoinicial + '/null/null/null/' + expl_tematica + '/json/' + _this.tk + '?callback=?') : (_this.servicio + '/API.svc/MetadatoIndicador/' + expl_idioma + '/' + indicador + '/' + ageoinicial + '/null/null/' + expl_tematica + '/json/' + _this.tk + '?callback=?');
2344            var title = document.getElementById("titletablero_" + _this.id).innerText;
2345            $.getJSON(url, null, function (data) {
2346                title= data.NOMBRE_INDICADOR + (data.NOMBRE_UNIDAD !== "" && data.NOMBRE_UNIDAD !== null ? " (" + data.NOMBRE_UNIDAD + ")" : "");
2347                var listaTodasLasCifras = data.CIFRAS_ESTATUS;
2348                ultPeriodo = listaTodasLasCifras.length > 0 ? listaTodasLasCifras[listaTodasLasCifras.length - 1].periodos : document.getElementById("up_" + _this.id).innerText;
2349
2350                var parametrosD3 = {};
2351                var fuenteAdicional = [{ "nombreF": "Fuente adicional", url: "https://www.inegi.org.mx" }];
2352                parametrosD3.id = 'componenteMapa' + _this.id;
2353                parametrosD3.indica = indicador;
2354
2355                //28/07/2023
2356                //En llamada con Claudia y Sergio Nieto se me comento que siempre se debe enviar el
2357                // área geográfica nacional para desplegar el mapa.
2358                /*parametrosD3.ageo = _this.obtieneClaveAgeo("municipal");*/
2359                parametrosD3.ageo = "00";
2360                parametrosD3.pf = ultPeriodo
2361                parametrosD3.muv = true;
2362                parametrosD3.mum = true;
2363                parametrosD3.mf = true;
2364                parametrosD3.mestra = true
2365                parametrosD3.estra = "1";
2366                parametrosD3.mpaleta = true;
2367                parametrosD3.fadd = fuenteAdicional;
2368                //Se agrega parámetro de temática
2369                parametrosD3.tm = expl_tematica;
2370                crearMapaTematicoD3(parametrosD3);
2371            });
2372
2373        },
2374        takeHerramienta: function (tematica) {
2375            var _this = this;
2376            var herramienta = "6";
2377            switch (tematica) {
2378                case "6":
2379                case "0":
2380                    herramienta = "6";
2381                    break;
2382                case "3":
2383                    herramienta = "34";
2384                    break;
2385                case "7":
2386                    herramienta = "30";
2387                    break;
2388                case "8":
2389                    herramienta = "28";
2390                    break;
2391                case "9":
2392                    herramienta = "47";
2393                    break;
2394            }
2395
2396            if (window.location.href.toLowerCase().indexOf("estructura.aspx") !== -1) {
2397                herramienta = "47";
2398            }
2399            //if (window.location.href.toLowerCase().indexOf("/app/buscador") !== -1) {
2400            //    herramienta = "71";
2401            //}
2402            if (window.location.href.toLowerCase().indexOf("/app/areasgeograficas") !== -1) {
2403                herramienta = "205";
2404            }
2405
2406            return herramienta;
2407        },
2408        checaPeriodo: function (indicador) {
2409            var _this = this;
2410            var ultPeriodo;
2411            //var ageoinicial = document.getElementById("agr_" + _this.id).innerText.trim();
2412
2413            //28/07/2023
2414            //En llamada con Claudia y Sergio Nieto se me comento que siempre se debe enviar el
2415            // área geográfica nacional para desplegar el mapa.
2416            var ageoinicial = "0";
2417
2418            //23/04/2025
2419            //Por correo Claudia me pidio agregar mapa por entidad cuando el máximo desglose del indicador sea 3 y diferente del nacional
2420            //var ageoinicial = expl_desglose === "3" ? _this.obtieneClaveAgeo("municipal") : "0700";
2421            
2422            var url = _this.servicio.toUpperCase().indexOf("V1_2") != -1 || _this.servicio.toUpperCase().indexOf("V1_3") != -1 ? (_this.servicio + '/API.svc/MetadatoIndicador/' + expl_idioma + '/' + indicador + '/' + ageoinicial + '/null/null/null/' + expl_tematica + '/json/' + _this.tk + '?callback=?') : (_this.servicio + '/API.svc/MetadatoIndicador/' + expl_idioma + '/' + indicador + '/' + ageoinicial + '/null/null/' + expl_tematica + '/json/' + _this.tk + '?callback=?');
2423            var title = document.getElementById("titletablero_" + _this.id).innerText;
2424            $.getJSON(url, null, function (data) {
2425                title = data.NOMBRE_INDICADOR + (data.NOMBRE_UNIDAD !== "" && data.NOMBRE_UNIDAD !== null ? " (" + data.NOMBRE_UNIDAD + ")" : "");
2426                var listaTodasLasCifras = data.CIFRAS_ESTATUS;
2427                ultPeriodo = listaTodasLasCifras.length > 0 ? listaTodasLasCifras[listaTodasLasCifras.length - 1].periodos : document.getElementById("up_" + _this.id).innerText;
2428
2429                var parametrosD3 = {};
2430                var fuenteAdicional = [{ "nombreF": "Fuente adicional", url: "https://www.inegi.org.mx" }];
2431                parametrosD3.id = 'componenteMapa' + _this.id;
2432                parametrosD3.indica = indicador;
2433
2434                //28/07/2023
2435                //En llamada con Claudia y Sergio Nieto se me comento que siempre se debe enviar el
2436                //
2437
2438                if (expl_desglose === "3") {
2439                    //1310205
2440                    //parametrosD3.ageo = expl_ageo === "0" || expl_ageo==="00" ? "00" : _this.obtieneClaveAgeo("municipal");
2441
2442                    parametrosD3.ageo = expl_ageo === "0" || expl_ageo === "00" ? "00" : expl_ageo.length > 2 ? expl_ageo.substring(0, 2) : expl_ageo;
2443                    if (parametrosD3.ageo !== "00") {
2444                        parametrosD3.cobertura = "mun";
2445                    }
2446                
2447                } else {
2448                    //área geográfica nacional para desplegar el mapa.
2449
2450                    parametrosD3.ageo = "00";
2451                    //parametrosD3.ageo = expl_ageo;
2452                }
2453              
2454                parametrosD3.tm = expl_tematica;
2455                parametrosD3.herramienta = _this.takeHerramienta(expl_tematica);
2456                parametrosD3.estra = "1";
2457                parametrosD3.ordenEstrato = "asc";
2458                parametrosD3.mup = true;
2459                parametrosD3.mum = true;
2460                parametrosD3.muv = true;
2461                parametrosD3.mestra = true
2462                parametrosD3.mpaleta = true;
2463                parametrosD3.mf = true;
2464
2465                parametrosD3.pf = ultPeriodo
2466                parametrosD3.fadd = fuenteAdicional;
2467                //parametrosD3.mimpr = true;
2468                //parametrosD3.mxls = true;
2469                crearMapaTematicoD3(parametrosD3);
2470            });
2471
2472        },
2473        nuevollamadoMapa: function (indicador) {
2474            var _this = this;
2475            /*var ultPeriodo = document.getElementById("up_" + _this.id).innerText.trim();*/
2476            /*  if (checaPerdiodoBusq === "9999") {*/
2477            _this.checaPeriodo(indicador);
2478            //}
2479            //else {
2480            //    var parametrosD3 = {};
2481            //    var fuenteAdicional = [{ "nombreF": "Fuente adicional", url: "https://www.inegi.org.mx" }];
2482            //    parametrosD3.id = 'componenteMapa' + _this.id;
2483            //    parametrosD3.indica = indicador;
2484
2485            //    //parametrosD3.ageo = _this.obtieneClaveAgeo("municipal");
2486
2487            //    //28/07/2023
2488            //    //En llamada con Claudia y Sergio Nieto se me comento que siempre se debe enviar el
2489            //    // área geográfica nacional para desplegar el mapa.
2490
2491            //    parametrosD3.ageo = "00";
2492
2493            //    //25052022. Se envía el ultimo periodo el de la app de indicadores
2494            //    if (window.location.href.toLowerCase().indexOf("/app/indicadores") !== -1) {
2495            //        //parametrosD3.pf = expl_uanio;
2496            //        parametrosD3.pf = expl_per_mapa;
2497            //    }
2498            //    else {
2499            //        //parametrosD3.pf = ultPeriodo;
2500            //        parametrosD3.pf = expl_per_mapa;
2501            //    }
2502
2503            //    parametrosD3.muv = true;
2504            //    parametrosD3.mum = true;
2505            //    parametrosD3.mf = true;
2506            //    parametrosD3.fadd = fuenteAdicional;
2507
2508            //    //Se agrega parámetro de temática
2509            //    parametrosD3.tm = expl_tematica;
2510
2511            //    crearMapaTematicoD3(parametrosD3);
2512            //}
2513        },
2514        obtieneClaveAgeo: function (param_tipo) {
2515            var ageoTools = "";
2516            //if (expl_ageo.indexOf("0") > -1) {
2517            //    /*var ageoTempoSinPais = expl_ageo.substring(6, expl_ageo.length);*/
2518            //    if (param_tipo === "nacional_estatal") {
2519            //        ageoTools = expl_ageo.length === 4 ? "00" : expl_ageo.substring(6, 8);
2520            //    }
2521            //    if (param_tipo === "municipal") {
2522            //        //ageoGlobal.substring(6, 8); //ent
2523            //        //ageoGlobal.substring(9, ageoGlobal.length; //mun
2524            //        ageoTools = expl_ageo.length === 4 ? "00" : expl_ageo.substring(6, 8) + expl_ageo.substring(9, expl_ageo.length);
2525            //    }
2526            //}
2527            /*      else {*/
2528            if (expl_ageo === "0" || expl_ageo === "00") {
2529                ageoTools = expl_ageo;
2530            } else {
2531                if (expl_ageo.length === 2) {
2532                    if (param_tipo === "nacional_estatal") {
2533                        ageoTools = expl_ageo;
2534                    }
2535                    if (param_tipo === "municipal") {
2536                        ageoTools = expl_ageo;
2537                    }
2538                } else if (expl_ageo.length === 5) {
2539                    if (param_tipo === "nacional_estatal") {
2540                        ageoTools = expl_ageo.substring(0, 2);
2541                    }
2542                    if (param_tipo === "municipal") {
2543                        ageoTools = expl_ageo;
2544                    }
2545                }
2546            }
2547
2548/*            }*/
2549            return ageoTools;
2550        },
2551        obtieneClaveNacional: function (param_tipo) {
2552            var ageoTools = "";
2553            //if (expl_ageo.indexOf("0") > -1) {
2554            //    /*var ageoTempoSinPais = expl_ageo.substring(6, expl_ageo.length);*/
2555            //    if (param_tipo === "nacional_estatal") {
2556            //        ageoTools = expl_ageo.length === 4 ? "00" : expl_ageo.substring(6);
2557            //    }
2558            //    if (param_tipo === "municipal") {
2559            //        ageoTools = expl_ageo.length === 4 ? "00" : expl_ageo.substring(6, 8) + expl_ageo.substring(9, expl_ageo.length);
2560            //    }
2561            //}
2562            //else {
2563                if (expl_ageo.length === 2) {
2564                    if (param_tipo === "nacional_estatal") {
2565                        ageoTools = expl_ageo;
2566                    }
2567                    if (param_tipo === "municipal") {
2568                        ageoTools = expl_ageo;
2569                    }
2570                } else if (expl_ageo.length === 5) {
2571                    if (param_tipo === "nacional_estatal") {
2572                        ageoTools = expl_ageo.substring(0, 2);
2573                    }
2574                    if (param_tipo === "municipal") {
2575                        ageoTools = expl_ageo;
2576                    }
2577                }
2578            /*}*/
2579            return ageoTools;
2580        },
2581        /// <summary>   Consulta primero la frecuencia del indicador. </summary>
2582        /// <param name="indicador">    Clave de indicador. </param>
2583        /// <param name="cobertura">    Cobertura geografica. </param>
2584        /// <returns>   . </returns>
2585        //goPinta: function (indicador, cobertura) {
2586        //    var _this = this;
2587        //    // aqui consultar lapso
2588        //    _this.consultaFrecuencia(indicador, cobertura);
2589        //},
2590
2591        /// <summary>   Obtiene frecuencia para calcular escala. </summary>
2592        /// <param name="indicador">    The indicador. </param>
2593        /// <param name="ageo">         The ageo. </param>
2594        /// <returns>   . </returns>
2595        consultaFrecuencia: function (indicador, ageo, gr) {
2596            var _this = this;
2597            //var ruta = _this.servicio + "/indicador/" + indicador + "/" + ageo + "/" + expl_idioma + "/false/json/" + _this.tk + "?callback=?";
2598
2599            //03092024
2600            //var ageoTemp = expl_tematica === "3" ? "null" : ageo;
2601
2602            var tematica = (document.getElementById("help_" + _this.id).innerHTML.trim()).split("_")[1];
2603            var ruta = _this.servicio.toUpperCase().indexOf("V1_2") !== -1 || _this.servicio.toUpperCase().indexOf("V1_3") !== -1 ? (_this.servicio + "/API.svc/indicador/" + indicador + "/" + ageo + "/" + expl_idioma + "/false/" + tematica + "/json/" + _this.tk + "?callback=?") : (_this.servicio + "/API.svc/indicador/" + indicador + "/" + ageo + "/" + expl_idioma + "/false/json/" + _this.tk + "?callback=?");
2604
2605
2606            /* if (ruta.length > 250) {*/
2607            $.getJSON(ruta, null, function (data) {
2608                _this.calculaEscala(data, indicador, ageo, gr);
2609            });
2610            //} else {
2611            //    var param = {
2612            //        indicador:indicador,
2613            //        areaGeografica: ageo,
2614            //        idioma: expl_idioma,
2615            //        tematica: expl_tematica,
2616            //        formato: "json",
2617            //        token: _this.tk
2618            //    };
2619            //    var paramMetodo = JSON.stringify(param);
2620
2621            //    $.ajax({
2622            //        method: "POST",
2623            //        url: _this.servicio + '/API.svc/Indicador',
2624            //        contentType: "application/json; charset=utf-8",
2625            //        dataType: "json",
2626            //        data: paramMetodo,
2627            //        processData: true,
2628            //        success: function (data) {
2629            //            _this.calculaEscala(data, indicador, ageo, gr);
2630            //        },
2631            //        error: function (jqXHR, textStatus, errorThrown) {
2632            //            console.log(textStatus, errorThrown);
2633            //        }
2634            //    });
2635            //}
2636        },
2637
2638        /// <summary>   Calcula escala de periodos de acuerdo a su frecuencia. </summary>
2639        /// <param name="data">         Datos en formato JSON. </param>
2640        /// <param name="indicador">    Clave de indicador. </param>
2641        /// <param name="ageo">         Clave de area geografica. </param>
2642        /// <returns>   . </returns>
2643        calculaEscala: function (data, indicador, ageo, gr) {
2644            if (data.ErrorCode === undefined) {
2645                var _this = this;
2646                if (data.MetaData !== null) {
2647                    //titulo para exportacion:
2648                    var exportacion = "";
2649                    //if (document.location.href.indexOf("desarrollowww") !== -1) {
2650                    //exportacion = data.MetaData.Factor !== null ? "(" + data.MetaData.Factor + ", " + data.MetaData.Unit + ")" : "(" + data.MetaData.Unit + ") " + (data.MetaData.Region !== null ? data.MetaData.Region : "");
2651                    exportacion = data.MetaData.Factor !== null && data.MetaData.Factor !== "" ? "(" + data.MetaData.Factor + (expl_idioma === "es" ? " de " : " of ") + data.MetaData.Unit + ")" : "(" + data.MetaData.Unit + ") " + expl_nombre;
2652                    //}
2653                    //else {
2654                    //    exportacion = "(" + data.MetaData.Unit + ") " + expl_nombre;
2655                    //}
2656
2657                    document.getElementById("exp_" + _this.id).innerText = exportacion;
2658
2659                    /*  var valorFrecuencia = data.MetaData.Freq;*/
2660                    var tituloIndicador = data.MetaData.Name;
2661                    document.getElementById("nombreInd" + _this.id).innerHTML = tituloIndicador;
2662                    var totalPeriodos = data.Data.Serie.length;
2663                    var escala = 1;
2664                    if (totalPeriodos > 10)
2665                        escala = parseInt(totalPeriodos / 10);
2666                    if (escala < 1)
2667                        escala = 1;
2668
2669
2670                    expl_escala = escala;
2671
2672                    if (gr) {
2673                        //pinta gráfica multicheck
2674                        _this.pintaGraficaMultiple(escala);
2675                    } else {
2676                        _this.pintaGraficaFin(indicador, ageo, escala);
2677                    }
2678                }
2679            }
2680            else {
2681                console.log(data);
2682            }
2683        },
2684
2685        /// <summary>   Dibuja grafica segun su escala. </summary>
2686        /// <param name="indicador">        Clave de indicador. </param>
2687        /// <param name="cobertura">        Cobertura geografica. </param>
2688        /// <param name="escalaPeriodos">   Escala de periodos. </param>
2689        /// <returns>   . </returns>
2690        pintaGraficaFin: function (indicador, cobertura, escalaPeriodos) {
2691            var _this = this;
2692            var inicioCadena = cobertura.substring(0, 1);
2693            /* var dirGrafica = _this.dirGrafica;*/
2694            var grafica = new GeneraGrafica();
2695            var datos = {};
2696            datos.ind = indicador;
2697            var areaFormateada = "";
2698            if (inicioCadena === "*" || inicioCadena === "'")
2699                areaFormateada = cobertura.substring(1, cobertura.length - 1);
2700            else
2701                areaFormateada = cobertura;
2702
2703
2704
2705            areaFormateada = areaFormateada === "0" ? "00" : areaFormateada;
2706            datos.ag = areaFormateada;
2707            datos.tg = _this.buscaTipoGrafica(indicador, cobertura, "Linea");
2708            datos.mn = "false";
2709            datos.mf = "false";
2710            datos.cbs = "false";
2711            datos.mu = "true";
2712            datos.dop = 1;
2713            datos.mfpu = "rango";
2714
2715            if (expl_colorGlobal !== "") {
2716                datos.cls = expl_colorGlobal;
2717            }
2718            datos.ix = escalaPeriodos.toString();
2719            datos.lang = expl_idioma;
2720
2721
2722            if (_this.servicio.toUpperCase().indexOf("V1_2") !== -1 || _this.servicio.toUpperCase().indexOf("V1_3") !== -1) {
2723                var tematica = (document.getElementById("help_" + _this.id).innerHTML.trim()).split("_")[1];
2724                datos.tematica = tematica;
2725            }
2726            var hayPrecision = JSON.parse(document.getElementById("precision_" + _this.id).innerHTML.trim());
2727            if (hayPrecision === true) {
2728                datos.tg = "Barra.B";
2729                datos.eb = "true";
2730                datos.tc = "precision";
2731            }
2732            else {
2733                if (window.location.href.indexOf("/app/indicesdeprecios/Estructura.aspx") !== -1) {
2734                    datos.export = false;
2735                } else {
2736                    datos.export = true;
2737                }
2738                datos.switch = true;
2739            }
2740
2741            datos.callback = function () {
2742                $("#btn_grafica" + _this.id).attr("disabled", false);
2743            };
2744
2745            grafica.CargaParametros("divGraficaExpl" + _this.id, datos);
2746
2747            var contenedor = document.getElementById("containerdivGraficaExpl" + _this.id);
2748            if (contenedor !== null) {
2749                //SNM 02_07_2019
2750                //document.getElementById("containerdivGraficaExpl" + _this.id).style.height = "250px";
2751                //document.getElementById("containerdivGraficaExpl" + _this.id).style.height = "400px";
2752                _this.registraEvento();
2753            }
2754        },
2755
2756        /// <summary>   Pinta grafica de comparativo por entidades. </summary>
2757        /// <returns>   . </returns>
2758        pintaGraficaComparativo: function (indicador) {
2759            var _this = this;
2760
2761            //28/072023
2762            //En llamada con Sergio Nieto y Claudia se comento en quitar el combo de selección múltiple 
2763            $("#selecAgeo_" + _this.id).hide();
2764
2765            $("#btn_comparativo" + _this.id).attr("disabled", "disabled");
2766            /*var dirGrafica = _this.dirGrafica;*/
2767            var grafica = new GeneraGrafica();
2768            var datos = {};
2769            datos.ind = indicador.toString();
2770            if (datos.ind.length < 10)
2771                //datos.ag = "00";
2772                datos.ag = "0";
2773            else
2774                datos.ag = "entidades";
2775
2776
2777            if (expl_pais === true) {
2778                if (array_pais.length > 0) {
2779                    datos.ag = array_pais.join(",");
2780                }
2781                else {
2782                    datos.ag = "entidades";
2783                }
2784            }
2785
2786            datos.tg = "Barra.A";
2787            datos.mn = "false";
2788            datos.mf = "false";
2789            datos.cbs = "false";
2790            datos.mu = "true";
2791            datos.dop = 1;
2792            datos.ord = "n";
2793            datos.ox = "h";
2794            datos.o = "h";
2795            datos.callback = function () {
2796                $("#btn_comparativo" + _this.id).attr("disabled", false);
2797            };
2798
2799            if (expl_colorGlobal !== "") {
2800                datos.cls = expl_colorGlobal;
2801            }
2802            datos.lang = expl_idioma;
2803
2804            if (_this.servicio.toUpperCase().indexOf("V1_2") !== -1 || _this.servicio.toUpperCase().indexOf("V1_3") !== -1) {
2805                var tematica = (document.getElementById("help_" + _this.id).innerHTML.trim()).split("_")[1];
2806                datos.tematica = tematica;
2807            }
2808
2809            grafica.CargaParametros("divGrafComp" + _this.id, datos);
2810            var contenedor = document.getElementById("divGrafComp" + _this.id);
2811            if (contenedor !== null) {
2812                document.getElementById("divComparativoExpl" + _this.id).style.height = "580px";
2813                document.getElementById("divGrafComp" + _this.id).style.height = "580px";
2814            }
2815        },
2816
2817        /// <summary>   Pinta grafica de comparativo por entidades. </summary>
2818        /// <returns>   . </returns>
2819        pintaGraficaComparativoMunicipal: function (indicador) {
2820            var _this = this;
2821            municipios = [];
2822            //28/072023
2823            //En llamada con Sergio Nieto y Claudia se comento en quitar el combo de selección múltiple 
2824            $("#selecAgeo_" + _this.id).hide();
2825
2826            $("#btn_comparativo" + _this.id).attr("disabled", "disabled");
2827            var ageoinicial = document.getElementById("agr_" + _this.id).innerText.trim();
2828
2829            if (ageoinicial.length > 4) {
2830                //var ageotemp = ageoinicial.substring(6, 8);
2831                var ageotemp = ageoinicial;
2832                var ruta = _this.servicio + '/API.svc/CatalogoAreaGeograficaV3/' + ageotemp + '/' + indicador + '/null/null/' + expl_tematica + '/1/json/' + _this.tk + '?callback=?';
2833                $.getJSON(ruta, null, function (data) {
2834                   
2835                    var Lmunicipios = data[0].AREAS_GEOGRAFICAS_DEPENDIENTES;
2836                    for (var ag = 0; ag < Lmunicipios.length; ag++) {
2837                        municipios.push(Lmunicipios[ag].AREA_GEOGRAFICA);
2838                    }
2839
2840                    var grafica = new GeneraGrafica();
2841                    var datos = {};
2842                    datos.ind = indicador.toString();
2843                    datos.ag = municipios.join(",");
2844                    datos.tg = "Barra.A";
2845                    datos.mn = "false";
2846                    datos.mf = "false";
2847                    datos.cbs = "false";
2848                    datos.mu = "true";
2849                    datos.dop = 1;
2850                    datos.ord = "n";
2851                    datos.ox = "h";
2852                    datos.o = "h";
2853                    datos.pagcat = "true";
2854                    datos.callback = function () {
2855                        $("#btn_comparativo" + _this.id).attr("disabled", false);
2856                    };
2857
2858                    if (expl_colorGlobal !== "") {
2859                        datos.cls = expl_colorGlobal;
2860                    }
2861                    datos.lang = expl_idioma;
2862
2863                    if (_this.servicio.toUpperCase().indexOf("V1_2") !== -1 || _this.servicio.toUpperCase().indexOf("V1_3") !== -1) {
2864                        var tematica = (document.getElementById("help_" + _this.id).innerHTML.trim()).split("_")[1];
2865                        datos.tematica = tematica;
2866                    }
2867
2868                    grafica.CargaParametros("divGrafComp" + _this.id, datos);
2869                    var contenedor = document.getElementById("divGrafComp" + _this.id);
2870                    if (contenedor !== null) {
2871                        document.getElementById("divComparativoExpl" + _this.id).style.height = "580px";
2872                        document.getElementById("divGrafComp" + _this.id).style.height = "580px";
2873                    }
2874                });
2875            }
2876            else {
2877                _this.pintaGraficaComparativo(indicador);
2878            }
2879
2880        },
2881
2882        /// <summary>   Determina el tipo de grafica de barra o linea a dibujar. </summary>
2883        /// <param name="indicador">    Clave de indicador. </param>
2884        /// <param name="cobertura">    Cobertura geografica. </param>
2885        /// <param name="tipo">         Tipo de grafica (barra o linea). </param>
2886        /// <returns>   . </returns>
2887        buscaTipoGrafica: function (indicador, cobertura, tipo) {
2888            var tipoGrafica = "Barra.G";
2889            if (tipo === "Barra") {
2890                tipoGrafica = "Barra.G";
2891                if (indicador.toString().indexOf(",") > 0) {
2892                    tipoGrafica = "Barra.F";
2893                }
2894            }
2895            if (tipo === "Linea") {
2896                tipoGrafica = "Linea.B";
2897                if (indicador.toString().indexOf(",") > 0) {
2898                    tipoGrafica = "Linea.F";
2899                }
2900            }
2901            return tipoGrafica;
2902        },
2903
2904        cargaLibrerias: function () {
2905            var _this = this;
2906            var libreriasJS = [];
2907            //if (API_V.toUpperCase() === "V1_3") {
2908            if (API_V.toUpperCase().indexOf("V1_3") !== -1) {
2909                libreriasJS = [
2910                    { "url": "/componentes/mapad3v2/js/mapa-d3.js", "alias": "mapa-d3.min.js" },
2911                    { "url": "/componentes/biinegi/convertidorAreasGeo.min.js", "alias": "convert
2911idorAreasGeo.min.js" },
2912                    { "url": "/componentes/biinegi/highcharts.js", "alias": "highcharts.js" },
2913                    { "url": "/componentes/biinegi/generaGraficaComponente.min.js?v1.1", "alias": "generaGraficaComponente.min.js" },
2914                    { "url": "/componentes/biinegi/metadatoV3_V1_3.min.js?v1.3", "alias": "metadatoV3_V1_3.min.js" },
2915                    { "url": "/componentes/biinegi/calculadoraINP.min.js", "alias": "calculadoraINP.min.js" },
2916                    { "url": "/componentes/biinegi/dibujaCuadros.min.js?v1.1", "alias": "dibujaCuadros.min.js" },
2917                    //{ "url": "/componentes/biinegi/pdf/jspdf.debug.js", "alias": "jspdf.debug.js" },
2918                    //{ "url": "/componentes/biinegi/pdf/html2pdf.js", "alias": "html2pdf.js" },
2919                    { "url": "/componentes/biinegi/tree/SitioINEGI_TreeAgeoCheckBox.min.js", "alias": "SitioINEGI_TreeAgeoCheckBox.min.js" }
2920                    //{ "url": "https://d3js.org/d3.v4.min.js", "alias": "d3.v4.min.js" },
2921                    //{ "url": "https://d3js.org/topojson.v2.min.js", "alias": "topojson.v2.min.js" },
2922/*                    { "url": "https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.js", "alias": "tinycolor.js" },*/
2923                    //{ "url": "/componentes/mapad3/js/componented3.js", "alias": "componented3.js" },
2924                    //{ "url": "/componentes/mapad3/js/mapa-d3.js", "alias": "mapa-d3.js" },
2925                    //{ "url": "/componentes/mapaTematico/js/mapaimprimir.min.js", "alias": "mapaimprimir.min.js" },
2926
2927                ];
2928            }
2929            else {
2930                libreriasJS = [
2931                    { "url": "/componentes/mapad3v2/js/mapa-d3.js", "alias": "mapa-d3.min.js" },
2932                    { "url": "/componentes/biinegi/convertidorAreasGeo.min.js", "alias": "convertidorAreasGeo.min.js" },
2933                    { "url": "/componentes/biinegi/highcharts.js", "alias": "highcharts.js" },
2934                    { "url": "/componentes/biinegi/generaGraficaComponente.min.js?v1.1.4", "alias": "generaGraficaComponente.min.js" },
2935
2936                    { "url": "/componentes/biinegi/metadatoV3.min.js", "alias": "metadatoV3.min.js" },
2937                    { "url": "/componentes/biinegi/calculadoraINP.min.js", "alias": "calculadoraINP.min.js" },
2938                    { "url": "/componentes/biinegi/dibujaCuadros.min.js", "alias": "dibujaCuadros.min.js" },
2939
2940                    //{ "url": "/componentes/biinegi/pdf/jspdf.debug.js", "alias": "jspdf.debug.js" },
2941                    //{ "url": "/componentes/biinegi/pdf/html2pdf.js", "alias": "html2pdf.js" },
2942                    { "url": "/componentes/biinegi/tree/SitioINEGI_TreeAgeoCheckBox.min.js", "alias": "SitioINEGI_TreeAgeoCheckBox.min.js" }
2943                    
2944                    //{ "url": "https://d3js.org/d3.v4.min.js", "alias": "d3.v4.min.js" },
2945                    //{ "url": "https://d3js.org/topojson.v2.min.js", "alias": "topojson.v2.min.js" },
2946/*                    { "url": "https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.js", "alias": "tinycolor.js" },*/
2947                    //{ "url": "/componentes/mapad3/js/componented3.js", "alias": "componented3.js" },
2948                    //{ "url": "/componentes/mapad3/js/mapa-d3.js", "alias": "mapa-d3.js" },
2949                    //{ "url": "/componentes/mapaTematico/js/mapaimprimir.min.js", "alias": "mapaimprimir.min.js" },
2950
2951
2952
2953
2954                ];
2955            }
2956
2957            _this.libreriasV2(libreriasJS);
2958
2959            if (document.domain === "localhost") {
2960                _this.librerias("./styles/explorador.min.css", "css", "expl16", "explorador.min.css");
2961                _this.librerias("http://desarrollowww.inegi.org.mx/componentes/biinegi/styles/calculadoraINP.min.css", "css", "expl17", "calculadoraINP.min.css");
2962                _this.librerias("http://desarrollowww.inegi.org.mx/componentes/mapad3v2/css/style.css", "css", "expl18", "style.css");
2963
2964            }
2965            else {
2966                _this.librerias("/componentes/biinegi/styles/calculadoraINP.min.css", "css", "expl16", "calculadoraINP.min.css");
2967                _this.librerias("/componentes/biinegi/styles/explorador.min.css", "css", "expl17", "explorador.min.css");
2968                _this.librerias("/componentes/mapad3v2/css/style.css", "css", "expl18", "style.css");
2969                
2970            }
2971        },
2972
2973        librerias: function (libreria, ty, id, arch) {
2974            var cssId = id;
2975            var link = "";
2976            if (!document.getElementById(cssId)) {
2977                var head = document.getElementsByTagName('head')[0];
2978                if (ty === "css") {
2979                    link = document.createElement('link');
2980                    link.rel = 'stylesheet';
2981                    link.type = 'text/css';
2982                    link.id = cssId;
2983                    link.href = libreria;
2984                    if ($('link[href="' + libreria + '"]').length === 0) {
2985                        head.appendChild(link);
2986                    }
2987                }
2988                else {
2989                    link = document.createElement('script');
2990                    link.type = 'text/javascript';
2991                    link.id = cssId;
2992                    link.src = libreria;
2993                    if (libreria.indexOf("d3.v4") !== -1) {
2994                        link.charset = "utf-8";
2995                    }
2996                    if ($('script[src="' + libreria + '"]').length === 0) {
2997                        head.appendChild(link);
2998                    }
2999                }
3000            }
3001        },
3002
3003        libreriasV2: function (librerias, arch) {
3004            var jsId = "expl"; var url_library = "";
3005            var temp = document.domain == "localhost" ? "http://desarrollowww.inegi.org.mx" : "";
3006            var head = document.getElementsByTagName('head')[0];
3007            var scripts = $("script[src]");
3008            var link = "";
3009
3010            var siEsta = false;
3011            for (var l = 0; l < librerias.length; l++) {
3012                url_library = temp + librerias[l].url;
3013                siEsta = false;
3014                if ($('script[src="' + url_library + '"]').length === 0) {
3015                    for (var s = 0; s < scripts.length; s++) {
3016                        if (scripts[s].src.indexOf(librerias[l].alias) !== -1) {
3017                            siEsta = true;
3018                        }
3019                    }
3020                    if (!siEsta) {
3021                        link = document.createElement('script');
3022                        link.type = 'text/javascript';
3023                        link.id = (jsId + l).toString();
3024                        link.src = temp + librerias[l].url;
3025                        if (librerias[l].alias.indexOf("d3.v4") !== -1) {
3026                            link.charset = "utf-8";
3027                        }
3028                        head.appendChild(link);
3029                        siEsta = false;
3030                    }
3031                }
3032            }
3033
3034        },
3035        evento: function () {
3036            var _this = this; var container = _this.container;
3037            var registra = "newEvento" + container;
3038            if (document.addEventListener) {
3039                document.addEventListener(registra, onFinishExplorador, false);
3040            }
3041            else {
3042                document.attachEvent("onclick", onFinishExplorador);
3043            }
3044        },
3045        findBootstrapEnvironment: function () {
3046            var envs = ['xs', 'sm', 'md', 'lg'];
3047
3048            $el = $('<div>');
3049            $el.appendTo($('body'));
3050
3051            for (var i = envs.length - 1; i >= 0; i--) {
3052                var env = envs[i];
3053
3054                $el.addClass('hidden-' + env);
3055                if ($el.is(':hidden')) {
3056                    $el.remove();
3057                    return env
3058                }
3059            };
3060        },
3061
3062        registraEvento: function () {
3063            var _this = this;
3064            var container = _this.container;
3065            var modo = _this.findBootstrapEnvironment();
3066            if (modo !== "xs" && modo !== "sm") {
3067                $("button").tooltip({
3068                    'container': 'body',
3069                    'placement': 'top'
3070                });
3071            }
3072            else {
3073                $('[data-toggle="tooltip"]').tooltip("disable");
3074            }
3075            var registra = "newEvento" + container;
3076            var event = "";
3077            event = document.createEvent("CustomEvent");
3078            event.initCustomEvent(registra, false, false, {
3079                'container': _this.container
3080            });
3081            document.dispatchEvent(event);
3082        },
3083
3084        escapeRegExp: function (str) {
3085            return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
3086        },
3087
3088        //replaceAll: function (str, find, replace) {
3089        //    return str.replace(new RegExp(this.escapeRegExp(find), 'g'), replace);
3090        //},
3091        expCsvExplorador: function (indicador) {
3092            var _this = this;
3093            //var url = C_dominioBuscador + "app/indicadores/exportacion.aspx?cveser=" + indicador + "&ag=" + expl_ageoCmb + "&bie=false&aamin=1900&aamax=9999&ordena=a&ordenaPeriodo=ap&orientacion=v&frecuencia=Todo&estadistico=false&esquema=&bdesplaza=False&FileFormat=csv&tc=indicadorVertical&subapp=&tematica=6&name=Estados%20Unidos%20Mexicanos";
3094            var param_tematica = expl_tematica !== "inp" ? (window.location.href.toLowerCase().indexOf("estructura.aspx") !== -1 ? "0" : expl_tematica) : expl_tematica;
3095
3096            //var url = C_dominioBuscador + "app/indicadores/exportacion.aspx?cveser=" + indicador + "&ag=" + expl_ageoCmb + "&bie=" + expl_bie + "&aamin=1900&aamax=9999&ordena=a&ordenaPeriodo=ap&orientacion=v&frecuencia=Todo&estadistico=false&esquema=&bdesplaza=False&FileFormat=csv&tc=indicadorVertical&subapp=&tematica=" + param_tematica + "&name=" + expl_nombre;
3097            var url = C_dominioBuscador + "app/indicadores/exportacion.aspx?cveser=" + indicador + "&ag=" + expl_ageo + "&bie=" + expl_bie + "&aamin=1900&aamax=9999&ordena=a&ordenaPeriodo=ap&orientacion=v&frecuencia=Todo&estadistico=false&esquema=&bdesplaza=False&FileFormat=csv&tc=indicadorVertical&subapp=&tematica=" + param_tematica + "&name=" + expl_nombre;
3098            //document.location.href = url;
3099            // _this.iframExporta(url);
3100
3101            var win = window.open(url, "_parent", false);
3102            win.onload = function () {
3103                win.close();
3104            };
3105        },
3106
3107        trataExportacion: function (formato, indicador, contenedor, precision) {
3108            var _this = this;
3109
3110            //14/12/2022
3111            //se realiza ajuste para ver si el cuadro tiene notas (colores, caso precision y cobertura)
3112            var id_ = "divReglasPrecisionExportdivT" + contenedor.replace("#", "");
3113            var infoExtra = document.getElementById(id_) !== undefined ? (document.getElementById(id_) !== null ? ($("#" + id_).attr("informacion_extra") === "1" ? true : false) : false) : false;
3114
3115            if (formato === "pdf") {
3116                _this.exportaPDF(contenedor);
3117            } else {
3118                //if (precision === true) {
3119                if (infoExtra === true) {
3120                    // el llamado el exportacionexcel
3121                    switch (formato) {
3122                        case "xls":
3123                            _this.expExcelExplorador(contenedor);
3124                            break;
3125                        case "csv":
3126                            _this.expCSVExplorador(contenedor);
3127                    }
3128                } else {
3129                    // el llamado a la url
3130                    switch (formato) {
3131                        case "xls":
3132                            _this.expXlsExplorador(indicador);
3133                            break;
3134                        case "csv":
3135                            _this.expCsvExplorador(indicador);
3136                    }
3137                }
3138            }
3139        },
3140        expXlsExplorador: function (indicador) {
3141            var _this = this;
3142
3143            var param_tematica = expl_tematica !== "inp" ? (window.location.href.toLowerCase().indexOf("estructura.aspx") !== -1 ? "0" : expl_tematica) : expl_tematica;
3144            //var url = C_dominioBuscador + "app/indicadores/exportacion.aspx?cveser=" + indicador + "&ag=" + expl_ageoCmb + "&bie=false&aamin=1900&aamax=9999&ordena=a&ordenaPeriodo=ap&orientacion=v&frecuencia=Todo&estadistico=false&esquema=&bdesplaza=False&FileFormat=xls&tc=indicadorVertical&subapp=&tematica=6&name=Estados%20Unidos%20Mexicanos";
3145            //var url = C_dominioBuscador + "app/indicadores/exportacion.aspx?cveser=" + indicador + "&ag=" + expl_ageoCmb + "&bie=" + expl_bie + "&aamin=1900&aamax=9999&ordena=a&ordenaPeriodo=ap&orientacion=v&frecuencia=Todo&estadistico=false&esquema=&bdesplaza=False&FileFormat=xls&tc=indicadorVertical&subapp=&tematica=" + param_tematica + "&name=" + expl_nombre;
3146            var url = C_dominioBuscador + "app/indicadores/exportacion.aspx?cveser=" + indicador + "&ag=" + expl_ageo + "&bie=" + expl_bie + "&aamin=1900&aamax=9999&ordena=a&ordenaPeriodo=ap&orientacion=v&frecuencia=Todo&estadistico=false&esquema=&bdesplaza=False&FileFormat=xls&tc=indicadorVertical&subapp=&tematica=" + param_tematica + "&name=" + expl_nombre;
3147            
3148            
3149            //document.location.href = url;
3150            //_this.iframExporta(url);
3151
3152            var win = window.open(url, "_parent", false);
3153            win.onload = function () {
3154                win.close();
3155            };
3156
3157        },
3158
3159        iframExporta: function (url) {
3160            var control = document.getElementById("ifExportaMC");
3161            if (control === null) {
3162                var exportFrame = document.createElement("IFRAME");
3163                exportFrame.id = "ifExporta";
3164                exportFrame.src = url;
3165                exportFrame.width = 0;
3166                exportFrame.height = 0;
3167                document.body.appendChild(exportFrame);
3168            }
3169            else {
3170                control.src = url;
3171            }
3172        },
3173        exportaPDF: function (contenedor) {
3174            var _this = this;
3175            var ID = _this.id.replace("divMetadatoExpl", "");
3176
3177            //a pdf
3178            var anchoTabla = $("#divT" + ID).width() + 50;
3179            var altoTabla = $("#divT" + ID).height() + 50;
3180
3181            //var pdf = new jsPDF('p', 'pt', [anchoTabla, altoTabla]);
3182            //var canvas = pdf.canvas;
3183            //canvas.width = 8.5 * 72;
3184
3185            var pdf = new jsPDF('p', 'pt', 'a4');
3186            pdf.canvas.height = altoTabla;
3187            pdf.canvas.width = anchoTabla;
3188
3189            html2canvas($("#divT" + ID)[0], {
3190                onrendered: function (canvas) {
3191                    document.body.appendChild(canvas);
3192                    var ctx = canvas.getContext('2d');
3193                    ctx.scale(1, 1);
3194                    var imgData = canvas.toDataURL("image/png", 1.0);
3195                    var width = canvas.width;
3196                    var height = canvas.clientHeight;
3197                    pdf.addImage(imgData, 'PNG', 20, 20, (width - 10), (height));
3198                }
3199            });
3200
3201
3202            setTimeout(function () {
3203                pdf.save('Banco de Indicadores.pdf');
3204            }, 2000);
3205
3206
3207        },
3208        expExcelExplorador: function (contenedor) {
3209            var _this = this;
3210            var ID = _this.id.replace("divMetadatoExpl", "");
3211            //var ID = contenedor.replace("#divMetadatoExpl", "");
3212            var ua = window.navigator.userAgent;
3213            var msie = ua.indexOf("MSIE ");
3214            if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
3215                this.expExcelExploradorIE(contenedor);
3216            }
3217            else {
3218                var tableToExcel = (function () {
3219                    var uri = 'data:application/vnd.ms-excel;base64,'
3220                        , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
3221                        , base64 = function (s) {
3222                            return window.btoa(unescape(encodeURIComponent(s)));
3223                        }
3224                        , format = function (s, c) {
3225                            return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; });
3226                        };
3227                    return function (table, name) {
3228                        if (!table.nodeType) table = document.getElementById(table);
3229                        var ctx = {
3230                            worksheet: name || 'Worksheet', table: table.innerHTML
3231                        };
3232                        var blob = new Blob([format(template, ctx)]);
3233                        var blobURL = window.URL.createObjectURL(blob);
3234                        return blobURL;
3235                    };
3236                })();
3237
3238                var isFirefox = typeof InstallTrigger !== 'undefined';
3239                var uri = 'data:application/vnd.ms-excel;base64,'
3240                    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
3241                    , base64 = function (s) {
3242                        return window.btoa(unescape(encodeURIComponent(s)));
3243                    }
3244                    , format = function (s, c) {
3245                        return s.replace(/{(\w+)}/g,
3246                            function (m, p) {
3247                                return c[p];
3248                            });
3249                    };
3250
3251                var table = document.getElementById('divDatosdivT' + ID);
3252                var divMetadato = document.getElementById("divMetadatoExpl" + ID);
3253                var tituloInegi = expl_idioma === "en" ? "National Institute of Statistics and Geography (INEGI)" : "Instituto Nacional de Estadística y Geografía (INEGI)";
3254                var tituloBanco = JSON.parse(expl_bie) === true ? expl_idioma === "en" ? "Economic Information Bank (BIE)" : "Banco de Información Económica (BIE)" : expl_idioma === "en" ? "Bank Indicators" : "Banco de Indicadores";
3255                var tituloFecha = (expl_idioma === "en") ? "Consult Date: " : "Fecha de consulta: ";
3256
3257                var tableName = "<table>";
3258                tableName += "<tr><td colspan='2'><H4>" + tituloInegi + "</H4></td></tr>";
3259                tableName += "<tr><td colspan='2'><H5>" + tituloBanco + "</H5></td></tr>";
3260                tableName += "<tr><td colspan='2'>" + tituloFecha + this.getDateF() + "</td></tr>";
3261
3262                var x = document.getElementById("nombreInd" + ID) !== null ? document.getElementById("nombreInd" + ID).innerHTML : "";
3263                var y = document.getElementById("titulo_ind" + ID) !== null ? document.getElementById("titulo_ind" + ID).innerHTML : "";
3264                var um = document.getElementById("exp_" + ID).innerText.trim();
3265                //tableName += "<tr><td colspan='2'><b>" + x + " " + y + "</b></td></tr>";
3266                tableName += "<tr><td colspan='2'><b>" + x + " " + um + "</b></td></tr>";
3267                tableName += "<tr><td></td></tr>";
3268                tableName += "</table>";
3269                //var metadatoHtml = this.replaceAll(divMetadato.innerHTML, '<div data-role="none" class="m_titulos">', '<div data-role="none" class="m_titulos"><b>');
3270                //var metadatoHtml2 = this.replaceAll(metadatoHtml, '</div><div data-role="none" class=" m_textos"', '</b></div><div data-role="none" class=" m_textos"');
3271                //var metadatoHtml3 = this.replaceAll(metadatoHtml2, '</div><div data-role="none" class="  m_textos"', '</b></div><div data-role="none" class=" m_textos"');
3272                //var ctx = { worksheet: name || 'Worksheet', table: tableName + table.innerHTML + "<br\>" + metadatoHtml3 }
3273
3274                var htmlExportacion = metadatoControlV3("#divMetadatoExpl" + ID).getMetadatoExp();
3275                //var cuadroNotas = document.getElementById("divReglasPrecisiondivT" + ID);
3276                var cuadroNotas = document.getElementById("divReglasPrecisionExportdivT" + ID);
3277
3278                cuadroNotas.style.border = "1px solid #333";
3279
3280                //var ctx = { worksheet: name || 'Worksheet', table: tableName + table.innerHTML + "<br\>" + htmlExportacion + "<br\>" + cuadroNotas.innerHTML };
3281                var ctx = {
3282                    //worksheet: "Página 1" || 'Worksheet', table: tableName + table.innerHTML + "<br\>" + htmlExportacion + "<br\>" + cuadroNotas.innerHTML
3283                    worksheet: "Página 1" || 'Worksheet', table: tableName + table.innerHTML + "<br\>" + cuadroNotas.innerHTML + "<br\>" + htmlExportacion
3284                };
3285
3286                var link = "";
3287                if (isFirefox) {
3288                    link = document.createElement("a");
3289                    link.id = "clic_" + ID;
3290                    document.body.appendChild(link);
3291                    link.download = "Indicadores" + this.getDateF2() + ".xls";
3292                    link.href = uri + base64(format(template, ctx));
3293                    link.click();
3294                }
3295                else {
3296                    link = document.createElement("a");
3297                    link.download = "Indicadores" + this.getDateF2() + ".xls";
3298                    link.href = uri + base64(format(template, ctx));
3299                    link.id = "clic_" + ID;
3300                    link.click();
3301
3302                    //$("#clic_"+ID ).trigger("click");
3303                }
3304
3305            }
3306
3307        },
3308
3309        expCSVExplorador: function (contenedor) {
3310            var _this = this;
3311            var ID = _this.id.replace("divMetadatoExpl", "");
3312            var tablaHtml = null;
3313
3314
3315            var cuadroCifras = document.getElementById("tableCifrasdivT" + ID);
3316            var cifrasBodyRows = cuadroCifras.rows;
3317
3318            var cuadroNotas = document.getElementById("tableReglasPrecisiondivT" + ID);
3319            var notasBodyRows = cuadroNotas.rows;
3320
3321            var jumpLine = "\n";
3322            tablaHtml = document.getElementById('tableStatcontGraficadivT' + ID) || document.getElementById('tableStatdivT' + ID);
3323            // definicion de los elementos principales: tabla html de datos 
3324            var tablaHeader = tablaHtml.rows[0]
3325            var tablaHeaderRows = tablaHeader.children;
3326            var tablaBodyRows = tablaHtml.rows;
3327            var strContentCSV = "";
3328            // var strContentCSV = "data:text/csv;charset=utf-8,";
3329
3330            // agregamos encabezado titulos
3331            strContentCSV += "Instituto Nacional de Estadística y Geografía" + jumpLine + jumpLine;
3332            strContentCSV += "Banco de Indicadores" + jumpLine + jumpLine;
3333            strContentCSV += "Fecha de consulta:" + this.getDateF() + jumpLine + jumpLine + jumpLine;
3334
3335            //Extraemos los valores de la tabla html para meterlos en un string separados por coma
3336            //for (var r = 0; r < tablaBodyRows.length; r++) { // tr filas
3337            //    var aTdCols = tablaBodyRows[r].children;
3338            //    var aTdColsTotal = aTdCols.length;
3339            //    strContentCSV += jumpLine;
3340            //    for (var c = 0; c < aTdColsTotal; c++) { // tds columnas
3341            //        var nv = (aTdCols[c].innerHTML.indexOf(".") != -1) ? aTdCols[c].innerHTML.replace(/,/g, "") : aTdCols[c].innerHTML;
3342            //        console.log(nv)
3343            //        strContentCSV += nv + ","
3344            //    }
3345            //}
3346
3347            //Se corrige 19072023
3348            for (var r = 0; r < tablaBodyRows.length; r++) { // tr filas
3349                var aTdCols = tablaBodyRows[r].children;
3350                var aTdColsTotal = aTdCols.length;
3351                strContentCSV += jumpLine;
3352                for (var c = 0; c < aTdColsTotal; c++) { // tds columnas
3353                    var nv = (aTdCols[c].innerText.indexOf(".") != -1) ? aTdCols[c].innerText.replace(/,/g, "") : aTdCols[c].innerText.indexOf(",") != -1 ? aTdCols[c].innerText.replace(/,/g, "") : aTdCols[c].innerText;
3354                    /*                    console.log(nv)*/
3355                    strContentCSV += nv + ","
3356                }
3357            }
3358
3359            strContentCSV += jumpLine;
3360
3361            if (cifrasBodyRows.length > 0 || notasBodyRows.length > 0) {
3362                strContentCSV += "Notas y Llamadas";
3363            }
3364
3365            strContentCSV += jumpLine;
3366
3367            for (var ci = 0; ci < cifrasBodyRows.length; ci++) { // tr filas
3368                var aTdCols_cifras = cifrasBodyRows[ci].children;
3369                var aTdColsTotal_cifras = aTdCols_cifras.length;
3370                if (cifrasBodyRows[ci].innerText !== "") {
3371                    strContentCSV += jumpLine;
3372                }
3373                for (var cin = 0; cin < aTdColsTotal_cifras; cin++) { // tds columnas
3374                    var nvcifras = (aTdCols_cifras[cin].innerText.indexOf(",") != -1 ? aTdCols_cifras[cin].innerText.replace(/,/g, " ") : aTdCols_cifras[cin].innerText);
3375                    strContentCSV += nvcifras + ","
3376                }
3377            }
3378
3379            strContentCSV += jumpLine;
3380
3381            for (var n = 0; n < notasBodyRows.length; n++) { // tr filas
3382                var aTdCols_notas = notasBodyRows[n].children;
3383                var aTdColsTotal_notas = aTdCols_notas.length;
3384                if (notasBodyRows[n].innerText !== "") {
3385                    strContentCSV += jumpLine;
3386                }
3387                for (var cn = 0; cn < aTdColsTotal_notas; cn++) { // tds columnas
3388                    var nvnotas = (aTdCols_notas[cn].innerText.indexOf(",") != -1 ? aTdCols_notas[cn].innerText.replace(/,/g, " ") : aTdCols_notas[cn].innerText);
3389                    strContentCSV += nvnotas + ","
3390                }
3391            }
3392            /*            strContentCSV += cuadroNotas;*/
3393
3394
3395            // Genera el enlace al vuelo para la descarga del csv
3396            // Añade nombre
3397            // Al final elimina el link del html
3398            var linkFile = document.createElement("a");
3399            var blob = new Blob(["\ufeff", strContentCSV]);
3400            var url = URL.createObjectURL(blob);
3401            linkFile.href = url;
3402            linkFile.download = "Indicadores" + this.getDateF2() + ".csv";;
3403            document.body.appendChild(linkFile);
3404            linkFile.click();
3405            document.body.removeChild(linkFile);
3406        },
3407
3408        expExcelExploradorIE: function (componente) {
3409            var _this = this;
3410            var ID = componente.replace("#divMetadatoExpl", "");
3411            var ua = window.navigator.userAgent;
3412            var msie = ua.indexOf("MSIE ");
3413
3414            if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
3415                //var tab_text = "<table border='2px'><tr bgcolor='#87AFC6'>";
3416                var tab_text = "<table border='2px'><tr >";
3417                var textRange; var j = 0;
3418                var tituloInegi = expl_idioma === "en" ? "National Institute of Statistics and Geography (INEGI)" : "Instituto Nacional de Estadística y Geografía (INEGI)";
3419                var tituloBanco = expl_idioma === "en" ? "Bank Indicators" : "Banco de Indicadores";
3420                var tituloFecha = expl_idioma === "en" ? "Consult Date: " : "Fecha de consulta: ";
3421
3422                tab_text += "<tr><td><H4>" + tituloInegi + "</H4></td></tr>";
3423                tab_text += "<tr><td><H5>" + tituloBanco + "</H5></td></tr>";
3424                tab_text += "<tr><td>" + tituloFecha + this.getDateF() + "</td></tr>";
3425
3426                var x = document.getElementById("nombreInd" + ID) !== null ? document.getElementById("nombreInd" + ID).innerHTML : "";
3427                var y = document.getElementById("titulo_ind" + ID) !== null ? document.getElementById("titulo_ind" + ID).innerHTML : "";
3428
3429                tab_text += "<tr><td>" + x + " " + y + "</td></tr>";
3430
3431                tab_text += "<tr><td></td></tr>";
3432                tab = document.getElementById('tableStatdivT' + ID);
3433                tab_text += "<tr>";
3434                for (j = 0; j < tab.rows.length; j++) {
3435                    tab_text = tab_text + tab.rows[j].innerHTML + "</tr>";
3436                }
3437
3438                tab_text = tab_text + "<tr><td>";
3439                tab_text = tab_text + document.getElementById("divMetadatoExpl" + ID).innerHTML + "</td></tr>";
3440                tab_text = tab_text + "</table>";
3441                tab_text = tab_text.replace(/<A[^>]*>|<\/A>/g, "");
3442                tab_text = tab_text.replace(/<img[^>]*>/gi, "");
3443                tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, "");
3444
3445                ua = window.navigator.userAgent;
3446                msie = ua.indexOf("MSIE");
3447                var w = window.open();
3448
3449                w.document.write(tab_text);
3450                w.document.close();
3451
3452                sa = w.document.execCommand("SaveAs", true, "Indicadores" + this.getDateF2() + ".xls");
3453                w.document.write("");
3454                w.document.close();
3455                return sa;
3456            }
3457            else {
3458                this.expExcelExplorador(componente);
3459                return null;
3460            }
3461        },
3462
3463        getDateF: function () {
3464            var today = new Date();
3465            var dd = today.getDate();
3466            var mm = today.getMonth() + 1; //January is 0!
3467            var yyyy = today.getFullYear();
3468            Number.prototype.padLeft = function (base, chr) {
3469                var len = (String(base || 10).length - String(this).length) + 1;
3470                return len > 0 ? new Array(len).join(chr || '0') + this : this;
3471            };
3472
3473            var hh = today.getHours().padLeft();
3474            var nn = today.getMinutes().padLeft();
3475            var ss = today.getSeconds().padLeft();
3476
3477            if (dd < 10) {
3478                dd = '0' + dd;
3479            }
3480
3481            if (mm < 10) {
3482                mm = '0' + mm;
3483            }
3484            var todayFormated = dd + '/' + mm + '/' + yyyy + " " + hh + ":" + nn + ":" + ss;
3485            return todayFormated;
3486        },
3487
3488        getDateF2: function () {
3489            var today = new Date();
3490            var dd = today.getDate();
3491            var mm = today.getMonth() + 1; //January is 0!
3492            var yyyy = today.getFullYear();
3493            Number.prototype.padLeft = function (base, chr) {
3494                var len = (String(base || 10).length - String(this).length) + 1;
3495                return len > 0 ? new Array(len).join(chr || '0') + this : this;
3496            };
3497            var hh = today.getHours().padLeft();
3498            var nn = today.getMinutes().padLeft();
3499            var ss = today.getSeconds().padLeft();
3500
3501            if (dd < 10) {
3502                dd = '0' + dd;
3503            }
3504            if (mm < 10) {
3505                mm = '0' + mm;
3506            }
3507            var todayFormated = dd + mm + yyyy + hh + nn + ss;
3508            return todayFormated;
3509        },
3510
3511        setSizeMCMapa: function () {
3512            var _this = this;
3513            //if (document.URL.toLowerCase().indexOf("app/areasgeograficas/") != -1) {
3514            if (document.getElementById("divMapaExpl" + _this.id).style.display !== "none") {
3515                var ancho = $(window).width();
3516                if (ancho < 1000) {
3517                    /* var altura = parseInt($("#divGenM_componenteMapa" + _this.id).height()) + 500;*/
3518                    var altura = parseInt($("#divGearcomponenteMapa" + _this.id).height()) + 500;
3519                    var esCadena = isNaN(altura);
3520                    if (esCadena === false) {
3521                        $("#divMapaExpl" + _this.id).height(altura);
3522                    }
3523                    else {
3524                        /*                        $("#divMapaExpl" + _this.id).height(700);*/
3525                        /* $("#divMapaExpl" + _this.id).height(790);*/
3526                        $("#divMapaExpl" + _this.id).height("auto");
3527                    }
3528                    document.getElementById("divMapaExpl" + _this.id).style.display = "block";
3529                }
3530                else {
3531                    $("#divMapaExpl" + _this.id).height(500);
3532                    document.getElementById("divMapaExpl" + _this.id).style.display = "inline";
3533                }
3534
3535                if (document.URL.toLowerCase().indexOf("app/buscador/") !== -1) {
3536                    if (document.getElementById("cargaMapa") !== null) {
3537                        document.getElementById("cargaMapa").style.display = "none";
3538                    }
3539                }
3540
3541            }
3542            //}
3543        }
3544    };
3545    if (!window.exploradorDatos) {
3546        window.exploradorDatos = exploradorDatos;
3547    }
3548})();
3549
3550$(window).resize(function () {
3551    setSizesMapa();
3552});
3553
3554function setSizesMapa() {
3555    if (document.URL.toLowerCase().indexOf("app/indicadores/") !== -1) {
3556        if (document.getElementById("FastViewContainer") !== undefined) {
3557            if (document.getElementById("FastViewContainer") !== null) {
3558                if (document.getElementById("FastViewContainer").style.display === "block") {
3559                    var ID = "divfastview";
3560                    if (document.getElementById("divMapaExpl" + ID).style.display !== "none") {
3561                        var ancho = $(window).width();
3562                        if (ancho < 1000) {
3563                            /* var altura = parseInt($("#divGenM_componenteMapa" + ID).height()) + 500;*/
3564                            var altura = parseInt($("#divGearcomponenteMapa" + ID).height()) + 500;
3565                            var esCadena = isNaN(altura);
3566                            if (esCadena === false) {
3567                                $("#divMapaExpl" + ID).height(altura);
3568                            }
3569                            else {
3570                                $("#divMapaExpl" + ID).height(700);
3571                            }
3572                            document.getElementById("divMapaExpl" + ID).style.display = "block";
3573                        }
3574                        else {
3575                            $("#divMapaExpl" + ID).height(500);
3576                            document.getElementById("divMapaExpl" + ID).style.display = "inline";
3577                        }
3578                    }
3579                }
3580            }
3581        }
3582    }
3583}
3584
3585//regreso del evento para combos de áreas geográficas
3586function onCliCombo(e) {
3587    var display = exploradorDatos(e.detail.contenedor).validaComparativo();
3588    var hayPrecision = JSON.parse(document.getElementById("precision_" + e.detail.id).innerHTML.trim());
3589
3590    if (expl_desglose === "4") {
3591        if (expl_vistaInicial === "grafica" && expl_selecAgeo === true) {
3592
3593            if (display !== "none") {
3594                $("#btn_comparativo" + e.detail.id).show();
3595            }
3596            expl_ageo = e.detail.ageo;
3597            //12072024
3598            /*expl_desglose = expl_desglose === "4" ? "2" : expl_desglose;*/
3599            exploradorDatos(e.detail.contenedor).cargaInicial(expl_vistaInicial, e.detail.indicador);
3600        }
3601        else {
3602            if (display !== "none") {
3603                $("#btn_comparativo" + e.detail.id).show();
3604            }
3605            expl_ageo = e.detail.ageo;
3606             //12072024
3607            /*expl_desglose = expl_desglose === "4" ? "2" : expl_desglose;*/
3608            exploradorDatos(e.detail.contenedor).cargaInicial(expl_vistaInicial, e.detail.indicador);
3609        }
3610    }
3611
3612    else {
3613
3614        if (expl_vistaInicial !== "grafica" && expl_selecAgeo === true) {
3615            if (display !== "none") {
3616                $("#btn_comparativo" + e.detail.id).show();
3617            }
3618            expl_ageo = e.detail.ageo;
3619            expl_desglose = expl_desglose === "4" ? "2" : expl_desglose;
3620            exploradorDatos(e.detail.contenedor).cargaInicial(expl_vistaInicial, e.detail.indicador);
3621        }
3622        if (hayPrecision) {
3623            //30/06/2025
3624            expl_ageo = e.detail.ageo;
3625            expl_desglose = expl_desglose === "4" ? "2" : expl_desglose;
3626
3627            exploradorDatos(e.detail.contenedor).cargaInicial(expl_vistaInicial, e.detail.indicador);
3628        }
3629
3630
3631        //29012026
3632        if (display === "none") {
3633            $("#btn_comparativo" + e.detail.id).hide();
3634        }
3635    }
3636}
3637
3638function onMultiChckAgeo(e) {
3639    var display = exploradorDatos(e.detail.contenedor).validaComparativo();
3640
3641    if (e.detail.continua === "true") {
3642        expl_pais = true;
3643        expl_selecAgeo = false;
3644        exploradorDatos("#" + e.detail.alterno).cargaInicial(expl_vistaInicial, e.detail.indicador);
3645    }
3646    else {
3647        if (display !== "none") {
3648            $("#btn_comparativo" + e.detail.alterno).show();
3649        }
3650        expl_ageomult = e.detail.ageo;
3651
3652        //Lllamado de ageo para todos (metadato, tabla, grafica)
3653        /*    expl_ageo = expl_ageomult.length > 8 ? expl_ageomult.substring(0, 8) : expl_ageomult;*/
3654        if (e.detail.pais !== "true") {
3655            expl_ageo = exploradorDatos("#" + e.detail.alterno).traeCheck(expl_ageomult);
3656        }
3657        //
3658
3659        expl_desglose = expl_desglose === "4" ? "2" : expl_desglose;
3660        exploradorDatos("#" + e.detail.alterno).cargaInicial(expl_vistaInicial, e.detail.indicador);
3661
3662        //Trata combo área geográfica normal
3663        var ageo_select, trata;
3664        if (e.detail.pais !== "true") {
3665            ageo_select = document.getElementById("combo_enti_" + e.detail.alterno).value;
3666            //trata = expl_ageo.length > 8 ? expl_ageo.substring(0, 8) : expl_ageo;
3667            trata = expl_ageo;
3668            if (ageo_select !== trata) {
3669                exploradorDatos("#" + e.detail.alterno).construyeCombosAgeo(expl_ageo, e.detail.indicador);
3670            }
3671        }
3672        else {
3673            //Pais
3674            expl_pais = true;
3675            ageo_select = e.detail.ageo.split(",")[e.detail.ageo.split(",").length - 1];
3676            //trata = expl_ageo.length > 8 ? expl_ageo.substring(0, 8) : expl_ageo;
3677            trata = expl_ageo;
3678            expl_ageo = exploradorDatos("#" + e.detail.alterno).traeCheck(expl_ageomult);
3679            if (ageo_select !== trata) {
3680                exploradorDatos("#" + e.detail.alterno).construyeCombosAgeo(ageo_select, e.detail.indicador);
3681            }
3682
3683        }
3684    }
3685}
3686
3687(function () {
3688    var about = function () {
3689    }
3690    var areaGeo_Component = function (params) {
3691        return new Library(params);
3692    };
3693    var Library = function (params) {
3694        if (params) {
3695            configura(params).init();
3696            var selector = document.querySelectorAll(params),
3697                i = 0;
3698            this.length = selector.length;
3699            this.id = selector[this.length - 1].id;
3700            this.dominio = C_dominio;
3701            this.tk = C_token;
3702            this.servicio = C_direccionServicio_V + "_" + API_V;
3703            this.container = params;
3704            for (; i < this.length; i++) {
3705                this[i] = selector[i];
3706            }
3707            return this;
3708        }
3709        else {
3710            return about();
3711        }
3712    };
3713    areaGeo_Component.fn = Library.prototype =
3714    {
3715        init: function (ageo, ind, desglose, filtrosAdicionales, tematica, ty, content, seleccion) {
3716            var _this = this;
3717            //var coberGeo = "0700";
3718            //var param_desglose = coberGeo !== "null" ? "null" : desglose;
3719            //var param_ageo = param_desglose !== "null" ? "null" : coberGeo;
3720
3721            //var param_desglose = "null";
3722            //var param_desglose = expl_desglose === "4" ? "3" : expl_desglose;
3723            var param_desglose = expl_desglose;
3724
3725            //12072024
3726            //expl_desglose = expl_desglose === "4" ? "3" : expl_desglose;
3727
3728
3729            //var temp_ageo = desglose === "99" || desglose === "26" || desglose === "9" ? ageo : ageo;
3730            //var param_ageo = desglose === "99" || desglose === "26" || desglose === "9" ? ageo : (temp_ageo === "0" || temp_ageo === "00" ? temp_ageo : temp_ageo.length === 5 ? temp_ageo.substring(0, 2) : temp_ageo.substring(0, 1));
3731            //var param_seleccion = desglose === "99" || desglose === "26" || desglose === "9" ? seleccion : seleccion;
3732
3733            var temp_ageo = desglose === "99" || desglose === "26" || desglose === "9" ? ageo : ageo;
3734
3735            //
3736            var param_ageo = desglose === "99" || desglose === "26" || desglose === "9" ? ageo : (temp_ageo.length == 4 ? temp_ageo : "0");
3737            var param_seleccion = desglose === "99" || desglose === "26" || desglose === "9" ? seleccion : seleccion;
3738
3739
3740            _this.creaEvento();
3741            _this.generaComponente(param_desglose, ind, content, param_ageo, tematica, filtrosAdicionales, ty, param_seleccion);
3742        },
3743        creaEvento: function () {
3744            var registra = "newEventoCombos";
3745            if (document.addEventListener) {
3746                document.addEventListener(registra, onCliCombo, false);
3747            }
3748            else {
3749                document.attachEvent("onclick", onCliCombo);
3750            }
3751        },
3752        generaComponente: function (desglose, indicador, content, ageo, tematica, filtrosAd, ty, ageoSeleccion) {
3753            var _this = this;
3754            var contenedor = _this.container;
3755            var entra = false;
3756            var html = "";
3757            //if (desglose !== "1" || desglose === "null") {
3758            if (expl_desglose !== "1" && expl_desglose !== "99" && expl_desglose !== "26" && expl_desglose !== "9" || expl_desglose === "null") {
3759                entra = true;
3760                html += "<div class=\"col-xs-12 col-md-6\">";
3761                html += "<div class=\"row\" style=\"padding:10px 0px 10px 0px\">";
3762                if (expl_desglose === "2" || expl_desglose === "4") {
3763                    html += "<div class=\"col-sm-12 col-md-6\">";
3764                    html += "<select id=\"combo_enti_" + _this.id + "\" class=\"form-control\" onchange=\"javascript:areaGeo_Component('" + contenedor + "').goComboEnt(this.value,'" + indicador + "','" + desglose + "','" + tematica + "','" + ageoSeleccion + "');\"></select>";
3765                    html += " </div>";
3766                }
3767                if (expl_desglose === "3" || expl_desglose === "null") {
3768                    html += "<div class=\"col-sm-12 col-md-6\" style=\"padding-top:5px;\">";
3769                    html += "<select  id=\"combo_enti_" + _this.id + "\" class=\"form-control\" onchange=\"javascript:areaGeo_Component('" + contenedor + "').goComboEnt(this.value,'" + indicador + "','" + desglose + "','" + tematica + "','" + ageoSeleccion + "');\"></select>";
3770                    html += " </div>";
3771
3772                    html += "<div class=\"col-sm-12 col-md-6\" style=\"padding-top:5px;\">";
3773                    html += "<select style=\"display:none;\" id=\"combo_muni_" + _this.id + "\" class=\"form-control\" onchange=\"javascript:areaGeo_Component('" + contenedor + "').goComboMun(this.value,'" + indicador + "');\"></select>";
3774                    html += " </div>";
3775                }
3776
3777                html += "</div>"; //row
3778                html += "</div>";//col-xs-12
3779            }
3780            else {
3781                /* if (filtrosAd === "0" && ageo === "null" && indicador === "null") {*/
3782                if (desglose === "1" && tematica === "3" || desglose === "99" && tematica === "3" || desglose === "26" && tematica === "3" || desglose === "9" && tematica === "3") {
3783                    entra = true;
3784                    //para mostrar menu de categorias de áreas geográficas
3785                    html += "<div class=\"col-xs-12 col-md-6\">";
3786                    html += "<div class=\"row\" style=\"padding:10px 0px 10px 0px\">";
3787
3788                    html += "<div class=\"col-sm-12 col-md-6\">";
3789                    html += "<select style=\"display:none;\" id=\"combo_cate_" + _this.id + "\" class=\"form-control\" onchange=\"javascript:areaGeo_Component('" + contenedor + "').goComboCat(this.value,'" + indicador + "','" + desglose + "','" + tematica + "','" + filtrosAd + "');\"></select>";
3790                    html += " </div>";
3791
3792                    html += "<div class=\"col-sm-12\" style=\"padding-top:5px;\">";
3793                    html += "<select  style=\"display:none;\" id=\"combo_enti_" + _this.id + "\" class=\"form-control\" onchange=\"javascript:areaGeo_Component('" + contenedor + "').goComboEnt(this.value,'" + indicador + "','" + desglose + "','" + tematica + "','" + ageoSeleccion + "');\"></select>";
3794                    html += " </div>";
3795
3796                    html += "<div class=\"col-sm-12\" style=\"padding-top:5px;\">";
3797                    html += "<select style=\"display:none;\" id=\"combo_muni_" + _this.id + "\" class=\"form-control\" onchange=\"javascript:areaGeo_Component('" + contenedor + "').goComboMun(this.value,'" + indicador + "');\"></select>";
3798                    html += " </div>";
3799
3800                    html += "</div>"; //row
3801                    html += "</div>";//col-xs-12
3802                }
3803            }
3804            if (entra) {
3805                document.getElementById(content).innerHTML = html;
3806                _this.llamaAPI(ageo, indicador, desglose, tematica, filtrosAd, ty, ageoSeleccion, true);
3807            }
3808            else {
3809                exploradorDatos(_this.container).cargaInicial(expl_vistaInicial, indicador);
3810            }
3811
3812            //document.getElementById(content).innerHTML = html;
3813            //_this.llamaAPI(ageo, indicador, desglose, tematica, filtrosAd, ty, ageoSeleccion);
3814        },
3815        llamaAPI: function (ageo, ind, desglose, tematica, filtrosAd, ty, ageoSeleccion, inicial) {
3816            var _this = this;
3817            var busqueda = "null";
3818            filtrosAd = "1";
3819            //var tempAgeo = desglose === "4" ?"null" :  desglose === "1" && tematica === "3" ? "null" : (desglose === "99" || desglose === "26" && tematica === "3" ? "null" : desglose === "9" && tematica === "3" ? "null" : ageo);
3820            var tempAgeo = desglose === "4" ?"null" :  desglose === "1" && tematica === "3" ? "null" : (desglose === "99" || desglose === "26" && tematica === "3" ? "null" : desglose === "9" && tematica === "3" ? "null" : ageo =="0"?"null" :ageo);
3821            var ruta = _this.servicio + '/API.svc/CatalogoAreaGeograficaV3/' + tempAgeo + '/' + ind + '/' + busqueda + '/null/' + tematica + '/' + filtrosAd + '/json/' + _this.tk + '?callback=?';
3822
3823            $.getJSON(ruta, null, function (data) {
3824
3825                //29012026
3826                if (data[0].AREAS_GEOGRAFICAS_DEPENDIENTES.length === 1) {
3827                    document.getElementById("uno_" + _this.id).innerText = "true";
3828                }
3829
3830                if (ty == "combos") {
3831                    //if (filtrosAd == "0" && ageo === "null" && ind === "
3831null") {
3832                    if (desglose === "1" && tematica === "3" || desglose === "99" || desglose === "26" && tematica === "3") { //detecta si hay paises
3833                        var lista;
3834                        if (desglose === "9"|| desglose === "99" || desglose === "26") {
3835                            lista = data[0].AREAS_GEOGRAFICAS_DEPENDIENTES.sort(_this.ordenaJsonV2("NOMBRE"));
3836                        }
3837                        else {
3838                            lista = data[0].AREAS_GEOGRAFICAS_DEPENDIENTES.sort(_this.ordenaJson("UBICACION_GEOGRAFICA"));
3839                        }
3840                        //if (lista.length == 1) {
3841                        //    $.getJSON(ruta, null, function (datos) {
3842                        //        _this.pintaCombos(datos, ageo, ind, ageoSeleccion, desglose, tematica);
3843                        //        $("#combo_enti_" + _this.id).show();
3844                        //    });
3845                        //}
3846                        //else {
3847                        if (lista.length > 1) {
3848                            //para mostrar menu de categorias de áreas geográficas
3849                            _this.pintaCategorias(lista, ind, tematica, ageo);
3850                        }
3851                    }
3852                    else {
3853                        _this.pintaCombos(data, ageo, ind, ageoSeleccion, desglose, tematica, inicial);
3854                    }
3855                }
3856            });
3857        },
3858        ordenaJson: function (property) {
3859            var sortOrder = 1;
3860            if (property[0] === "-") {
3861                sortOrder = -1;
3862                property = property.substr(1);
3863            }
3864            return function (a, b) {
3865                var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;
3866                return result * sortOrder;
3867            }
3868        },
3869        ordenaJsonV2: function (property) {
3870            var sortOrder = 1;
3871            var aA, bB;
3872            if (property[0] === "-") {
3873                sortOrder = -1;
3874                property = property.substr(1);
3875            }
3876
3877            return function (a, b) {
3878                aA = (a[property]).normalize("NFD").replace(/[\u0300-\u036f]/g, "");
3879                bB = (b[property]).normalize("NFD").replace(/[\u0300-\u036f]/g, "");
3880
3881                var result = (aA < bB) ? -1 : (aA > bB) ? 1 : 0;
3882                return result * sortOrder;
3883            }
3884        },
3885        vaciarCombo: function (nombrecombo) {
3886            var combo = document.getElementById(nombrecombo);
3887            while (combo.options.length > 0) {
3888                combo.options[combo.options.length - 1] = null;
3889            }
3890        },
3891        goComboCat: function (ageo, indicador, desglose, tematica, filtrosAd) {
3892            var _this = this;
3893            expl_inicia = false;
3894            /*_this.llamaAPI(ageo, indicador, "null", tematica, "1", "combos", "null");*/
3895            _this.detectedBoton(ageo, indicador, "combo_cate_");
3896            expl_ageoCmb = ageo;
3897        },
3898        goComboEnt: function (entidad, indicador, desglose, tematica, seleccion) {
3899            var _this = this;
3900            expl_inicia = false;
3901            //var param_desglose = entidad.length > 8 ? "3" : desglose;
3902
3903
3904            //if (param_desglose === "3" || param_desglose == "null") {
3905            if (expl_desglose === "3") {
3906                //12072024
3907                if (desglose === "4") {
3908                    $("#combo_muni_" + _this.id).hide();
3909                    expl_esMunicipal = false;
3910                    _this.detectedBoton(entidad, indicador, "combo_enti_");
3911                }
3912                else {
3913                    if (entidad !== "0" && entidad !== "00") {
3914                        $("#combo_muni_" + _this.id).show();
3915                        //_this.construyeCombosAgeo(entidad, indicador);
3916                        var param_entidad = seleccion.length > 8 ? entidad.substring(0, 8) : entidad;
3917                        _this.llamaAPI(param_entidad, indicador, expl_desglose, tematica, "1", "combos", seleccion, false);
3918                    }
3919                    else {
3920                        //Nacional
3921                        $("#combo_muni_" + _this.id).hide();
3922                        expl_esMunicipal = false;
3923                        _this.detectedBoton(entidad, indicador, "combo_enti_");
3924                    }
3925                }
3926            }
3927            else {
3928                _this.detectedBoton(entidad, indicador, "combo_enti_");
3929            }
3930            expl_ageoCmb = entidad;
3931        },
3932        goComboMun: function (municipio, indicador) {
3933            var _this = this;
3934            expl_inicia = false;
3935            expl_esMunicipal = true;
3936            var areageo = (municipio).toString();
3937            expl_ageoCmb = areageo;
3938            _this.detectedBoton(areageo, indicador, "combo_muni_");
3939        },
3940        detectedBoton: function (ageo, indicador, ty) {
3941            var _this = this;
3942
3943            var registra = "newEventoCombos";
3944            var event = "";
3945            event = document.createEvent("CustomEvent");
3946            event.initCustomEvent(registra, false, false, {
3947                'id': _this.id,
3948                'contenedor': _this.container,
3949                'ageo': ageo,
3950                'indicador': indicador,
3951                'combo': ty
3952            });
3953            document.dispatchEvent(event);
3954        },
3955        pintaCategorias: function (data, ind, tematica, ageo) {
3956            var _this = this;
3957            array_pais = [];
3958            var combo = document.getElementById("combo_cate_" + _this.id);
3959            var posi = 0;
3960            var nameFinal = '';
3961            data = data.sort(_this.ordenaJsonV2("NOMBRE"));
3962            if (data.length > 1) {
3963                //se pinta menú de categorización
3964                for (var e = 0; e < data.length; e++) {
3965                    nameFinal = data[e].DESGLOSE_GEOGRAFICO !== 1 && data[e].DESGLOSE_GEOGRAFICO !== 26 ? (_this.traeClaveAgeo(data[e].AREA_GEOGRAFICA, data[e].NOMBRE)) : data[e].NOMBRE;
3966                    array_pais.push(data[e].AREA_GEOGRAFICA);
3967                    combo.options[e] = new Option();
3968                    //combo.options[e].text = data[e].NOMBRE;
3969                    //combo.options[e].innerHTML = "<span class=\"notranslate\">" + data[e].NOMBRE + "</span>";
3970
3971                    combo.options[e].text = nameFinal;
3972                    combo.options[e].innerHTML = "<span class=\"notranslate\">" + nameFinal + "</span>";
3973
3974                    //combo.options[e].title = data[e].NOMBRE;
3975                    combo.options[e].value = data[e].AREA_GEOGRAFICA;
3976                    if (data[e].AREA_GEOGRAFICA === ageo) {
3977                        combo.options[e].selected = true;
3978                    }
3979                }
3980               /* combo.options[posi].selected = true;*/
3981                $("#combo_cate_" + _this.id).show();
3982            }
3983            else {
3984                if (data.length === 1) {
3985                    $("#combo_cate_" + _this.id).hide();
3986                    _this.llamaAPI(data[0].AREA_GEOGRAFICA, ind, "null", tematica, "1", "combos", "null", false);
3987                }
3988            }
3989        },
3990        //traeClaveAgeo(clave, name) {
3991        //    var clavetemp = '';
3992        //    if (clave.length == 4) {
3993        //        //nacional
3994        //        clavetemp = "00";
3995        //    }
3996        //    else if (clave.length > 8) {
3997        //        //municipal
3998        //        /* clavetemp = clave.substring(6, 8) + clave.substring(9, clave.length - 9);*/
3999        //        clavetemp = clave.substring(6, 8) + clave.substring(9, clave.length);
4000        //    }
4001        //    else {
4002        //        //estatal
4003        //        clavetemp = clave.substring(6, 8);
4004
4005        //    }
4006        //    return clavetemp + " " + name;
4007        //},
4008        traeClaveAgeo(clave, name) {
4009            var clavetemp = '';
4010            if (clave === "0" || clave ==="00") {
4011                //nacional
4012                clavetemp = "00";
4013            }
4014            else if (clave.length > 5) {
4015                //municipal
4016                clavetemp = clave;
4017            }
4018            else {
4019                //estatal
4020                clavetemp = clave;
4021
4022            }
4023            return clavetemp + " " + name;
4024        },
4025        pintaCombos: function (lista, entidad, indicador, ageoSeleccion, desglose, tematica, inicial) {
4026            var _this = this;
4027            //var name = entidad.length <= 4 ? "combo_enti_" + _this.id : "combo_muni_" + _this.id;
4028            //var name = entidad === "0" || entidad === "00" || entidad.length === 4 ? "combo_enti_" + _this.id : "combo_muni_" + _this.id;
4029            //var name = entidad.length === 2 && ageoSeleccion.length === 5 ? "combo_enti_" + _this.id : (entidad === "0" || entidad === "00" || entidad.length === 4 ? "combo_enti_" + _this.id : "combo_muni_" + _this.id);
4030            var name = entidad.length === 1  ? "combo_enti_" + _this.id : "combo_muni_" + _this.id;
4031
4032           
4033            var data = lista;
4034            var nameFinal = '';
4035            var value_entidad = "";
4036            var combo = document.getElementById(name);
4037            //var number_seleccion = name.indexOf("combo_enti_") !== -1 ? (ageoSeleccion.length == 4 ? ageoSeleccion : ageoSeleccion.substring(0, 8)) : ageoSeleccion;
4038            //var number_seleccion = name.indexOf("combo_enti_") !== -1 ? (ageoSeleccion.length == 1 || ageoSeleccion == "0" || ageoSeleccion == "00" ? ageoSeleccion : ageoSeleccion.substring(0, 2)) : ageoSeleccion;
4039
4040            var number_seleccion = name.indexOf("combo_enti_") !== -1 ? (ageoSeleccion.length == 1? ageoSeleccion : ageoSeleccion.substring(0, 2)) : ageoSeleccion;
4041
4042            var posi = 0;
4043            var op = 0;
4044            if (data.length > 1) {
4045                for (var e = 0; e < data.length; e++) {
4046                    combo.options[e] = new Option();
4047                    combo.options[e].text = data[e].NOMBRE;
4048                    combo.options[e].innerHTML = "<span class=\"notranslate\">" + data[e].NOMBRE + "</span>";
4049                    //combo.options[e].title = data[e].NOMBRE;
4050                    combo.options[e].value = data[e].AREA_GEOGRAFICA;
4051                }
4052                combo.options[posi].selected = true;
4053                //$("#" + name).show();
4054            }
4055            else {
4056                if (data[0] != null) {
4057                    if (data[0].AREAS_GEOGRAFICAS_DEPENDIENTES !== null) {
4058                        var bandera = false;
4059                        if (name === "combo_muni_" + _this.id) {
4060                            _this.vaciarCombo(name);
4061                        }
4062
4063                        //04/12/2024
4064                        //if (data[0].NOMBRE !== "") {
4065                        //    combo.options[op] = new Option();
4066                        //    var texto = "";
4067                        //    if (data[0].AREA_GEOGRAFICA != "0700") {
4068                        //        texto = data[0].NOMBRE_DESGLOSE_GEOGRAFICO;
4069                        //    }
4070                        //    else {
4071                        //        nameFinal = _this.traeClaveAgeo(data[0].AREA_GEOGRAFICA, data[0].NOMBRE);
4072                        //        texto = expl_idioma == "es" ? data[0].NOMBRE == "Estatal" ? "Total estatal" : nameFinal : (data[0].NOMBRE == "Estatal" ? "Total state" : nameFinal);
4073                        //    }
4074                        //    combo.options[op].text = texto;
4075                        //    combo.options[op].innerHTML = "<span class=\"notranslate\">" + texto + "</span>";
4076                        //    combo.options[op].value = data[0].AREA_GEOGRAFICA;
4077                        //    op++;
4078                        //    posi++;
4079                        //}
4080
4081                        var listado;
4082                        if (desglose === "4" || desglose === "9" || desglose === "99" || desglose === "26") {
4083                            listado = data[0].AREAS_GEOGRAFICAS_DEPENDIENTES.sort(_this.ordenaJsonV2("NOMBRE"));
4084                        } else {
4085                            listado = data[0].AREAS_GEOGRAFICAS_DEPENDIENTES;
4086                        }
4087                        var nameFinal2 = '';
4088                        var pinta;
4089                        for (var e = 0; e < listado.length; e++) {
4090                            //04/12/2024
4091                            //pinta = listado[e].AREA_GEOGRAFICA !== entidad ? true : inicial === false  ? false : true;
4092                            pinta = true;
4093                            if (pinta) {
4094                                if(desglose==="3"){
4095                                    if(listado[e].DESGLOSE_GEOGRAFICO < 3){
4096                                        nameFinal2 = (desglose === "4" || desglose === "99" || desglose === "26" || desglose === "9") ? listado[e].NOMBRE : (_this.traeClaveAgeo(listado[e].AREA_GEOGRAFICA, listado[e].NOMBRE));
4097                                        combo.options[op] = new Option();
4098                                        combo.options[op].text = nameFinal2;
4099                                        combo.options[op].innerHTML = "<span class=\"notranslate\">" + nameFinal2 + "</span>";
4100
4101                                        combo.options[op].value = listado[e].AREA_GEOGRAFICA;
4102                                        if (listado[e].AREA_GEOGRAFICA === number_seleccion) {
4103                                            posi = posi + e;
4104                                            bandera = true;
4105                                        }
4106
4107                                        //amcr 12072024
4108                                        if (listado[e].DESGLOSE_GEOGRAFICO.toString() === "4") {
4109                                            if (e === 0) {
4110                                                bandera = true;
4111                                            }
4112                                        }
4113                                        op++;
4114                                    }
4115                                }else{
4116
4117                                    nameFinal2 = (desglose === "4" || desglose === "99" || desglose === "26" || desglose === "9") ? listado[e].NOMBRE : (_this.traeClaveAgeo(listado[e].AREA_GEOGRAFICA, listado[e].NOMBRE));
4118                                    combo.options[op] = new Option();
4119                                    combo.options[op].text = nameFinal2;
4120                                    combo.options[op].innerHTML = "<span class=\"notranslate\">" + nameFinal2 + "</span>";
4121
4122                                    combo.options[op].value = listado[e].AREA_GEOGRAFICA;
4123                                    if (listado[e].AREA_GEOGRAFICA === number_seleccion) {
4124                                        posi = posi + e;
4125                                        bandera = true;
4126                                    }
4127
4128                                    //amcr 12072024
4129                                    if (listado[e].DESGLOSE_GEOGRAFICO.toString() === "4") {
4130                                        if (e === 0) {
4131                                            bandera = true;
4132                                        }
4133                                    }
4134                                    op++;
4135                                }
4136
4137
4138                            }//fin de validación 04/12/2024
4139                        }
4140                        if (bandera) {
4141                            combo.options[posi].selected = true;
4142                        }
4143                        else {
4144                            combo.options[0].selected = true;
4145                        }
4146                        value_entidad = combo.options[combo.selectedIndex].value;
4147
4148                        //05octubre2022
4149                        if (bandera && expl_desglose === "3" && entidad === "0") {
4150                            _this.goComboEnt(value_entidad, indicador, desglose, tematica, ageoSeleccion);
4151                        }
4152
4153                        if (expl_desglose === "3" && entidad === "null") {
4154                            if (value_entidad.length !== ageoSeleccio
4154n.length) {
4155                                _this.goComboEnt(value_entidad, indicador, desglose, tematica, ageoSeleccion);
4156                            }
4157                            else {
4158                                _this.detectedBoton(value_entidad, indicador, "combo_muni_");
4159                            }
4160                        }
4161                        else if (value_entidad.length !== ageoSeleccion.length) {
4162                            //05112019
4163                            //var tempS1 = (convertidorAreasGeo(_this.container).init(ageoSeleccion));
4164                            //var tempS2 = tempS1.length === 4 ? "00" : tempS1.substring(6, 8);
4165                            //if (value_entidad.substring(6, 8) !== tempS2) {
4166                            //    _this.detectedBoton(value_entidad, indicador, "combo_enti_");
4167                            //}
4168                            var tempS1 = ageoSeleccion;
4169                            var tempS2 = tempS1 === '00' || tempS1=== '0' ? "00" : tempS1.substring(0, 2);
4170                            if (value_entidad.substring(0, 2) !== tempS2) {
4171                                _this.detectedBoton(value_entidad, indicador, "combo_enti_");
4172                            }
4173                            else {
4174                                _this.goComboEnt(ageoSeleccion, indicador, desglose, tematica, ageoSeleccion);
4175                            }
4176                        }
4177                        else {
4178                            _this.detectedBoton(value_entidad, indicador, "combo_enti_");
4179                        }
4180                        $("#" + name).show();
4181                    }
4182                    else {
4183                        //$("#combo_enti_" + _this.id).hide();
4184
4185                        //AMCR-18092019
4186                        //if (name.indexOf("combo_muni_") !== -1) {
4187                        if (document.getElementById("combo_muni_" + _this.id).style.display !== "none") {
4188                            $("#combo_muni_" + _this.id).hide();
4189                        }
4190                        //}
4191                        expl_inicia = false;
4192                        value_entidad = data[0].AREA_GEOGRAFICA.length > 0 ? data[0].AREA_GEOGRAFICA : entidad;
4193                        _this.detectedBoton(value_entidad, indicador, "combo_enti_");
4194                    }
4195                }
4196                else {
4197                    if (name === "combo_muni_" + _this.id) {
4198                        $("#" + name).hide();
4199                        _this.detectedBoton(entidad, indicador, "combo_enti_");
4200
4201                    }
4202                }
4203            }
4204
4205        }
4206    };
4207    if (!window.areaGeo_Component) {
4208        window.areaGeo_Component = areaGeo_Component;
4209    }
4210})();
4211
4212
4213
4214function onClicAreageografica(e) {
4215    onClicAreageografica
4216    var display = exploradorDatos("#" + alterno_).validaComparativo();
4217    document.getElementById("haynacional_" + alterno_).innerText = e.detail.nacional !== undefined ? e.detail.nacional : "true";
4218    //if (e.detail.continua === "true") {
4219    //    expl_pais = true;
4220    //    expl_selecAgeo = false;
4221    //    exploradorDatos("#" + e.detail.alterno).cargaInicial(expl_vistaInicial, e.detail.indicador);
4222    //}
4223    //else {
4224        if (display !== "none") {
4225            $("#btn_comparativo" + alterno_).show();
4226        }
4227    //expl_ageomult = e.detail.ageo;
4228    expl_ageomult = e.detail.id.toString() === "undefined" ? (expl_desglose === "1" ? "0" : (e.detail.id.toString() === "undefined" ? "0" : e.detail.id)) : e.detail.id;
4229
4230        //Lllamado de ageo para todos (metadato, tabla, grafica)
4231        /*    expl_ageo = expl_ageomult.length > 8 ? expl_ageomult.substring(0, 8) : expl_ageomult;*/
4232/*        if (e.detail.pais !== "true") {*/
4233            expl_ageo = exploradorDatos("#" + alterno_).traeCheck(expl_ageomult);
4234      /*  }*/
4235        //
4236
4237        expl_desglose = expl_desglose === "4" ? "2" : expl_desglose;
4238        exploradorDatos("#" + alterno_).cargaInicial(expl_vistaInicial, expl_indicador);
4239
4240        //Trata combo área geográfica normal
4241        var ageo_select, trata;
4242/*        if (e.detail.pais !== "true") {*/
4243            ageo_select = document.getElementById("combo_enti_" + alterno_).value;
4244            /*trata = expl_ageo.length > 8 ? expl_ageo.substring(0, 8) : expl_ageo;*/
4245            trata = expl_ageo;
4246            if (ageo_select !== trata) {
4247                exploradorDatos("#" + alterno_).construyeCombosAgeo(expl_ageo, expl_indicador);
4248            }
4249/*        }*/
4250        //else {
4251        //    //Pais
4252        //    expl_pais = true;
4253        //    ageo_select = e.detail.ageo.split(",")[e.detail.ageo.split(",").length - 1];
4254        //    trata = expl_ageo.length > 8 ? expl_ageo.substring(0, 8) : expl_ageo;
4255        //    expl_ageo = exploradorDatos("#" + e.detail.alterno).traeCheck(expl_ageomult);
4256        //    if (ageo_select !== trata) {
4257        //        exploradorDatos("#" + e.detail.alterno).construyeCombosAgeo(ageo_select, e.detail.indicador);
4258        //    }
4259
4260        //}
4261/*    }*/
4262}
4263
4264function onDescAreageo(e) {
4265
4266}
4267
4268function onFinishAreageo(e) { }
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.