Skip to content

Instantly share code, notes, and snippets.

@redraw
Created June 24, 2023 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redraw/760037f18eb047d1ac611f9793a6f812 to your computer and use it in GitHub Desktop.
Save redraw/760037f18eb047d1ac611f9793a6f812 to your computer and use it in GitHub Desktop.
document.programPage.TOTALES = {}
document.programPage.__guardarTotales = function() {
const [ INICIAL, VIGENTE, EJECUTADO ] = $('.importe-cabecera-value').map((idx, item) => {
return parseFloat(item.innerText.replaceAll(".", "").replace(",", "."))
})
this.TOTALES = {
"Presupuesto Inicial": INICIAL,
"Presupuesto Vigente": VIGENTE,
"Ejecutado": EJECUTADO,
}
}
document.programPage.renderImporteGeneral = function (breadcrumb_div, label, importe) {
let importe_cabecera_key, importe_cabecera_value;
importe_cabecera_key = $('<div></div>').addClass("importe-cabecera-key").addClass('text-dark');
importe_cabecera_key.html(label);
importe_cabecera_value = $('<div></div>').addClass("importe-cabecera-value").addClass('text-primary');
const value = `${prettyNumber(importe)} (${(importe / this.TOTALES[label] * 100).toFixed(2)}%)`;
importe_cabecera_value.html(value);
breadcrumb_div.append(importe_cabecera_key);
breadcrumb_div.append(importe_cabecera_value);
}
document.programPage.generarGrafico = async function () {
try {
this.inhabilitarPaneles();
this.clearTextInput();
var year = $("#year-input").val();
var urlWithParameters = this.url + year;
const arbol = await ajaxCall({url: urlWithParameters, method: 'GET'});
this.datosArbol = arbol;
this.crearArbol(arbol);
this.__guardarTotales();
} catch(error) {
console.info(error);
}
}
document.programPage.__guardarTotales()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment