title = {
let renderedCandidates;
const renderCandidateTitle = (c, i = 0, all = []) => {
const scale = colors[c] || defaultColor;
return htl.html`<h3><span style="color: ${scale(
(defaultDomain[1] - defaultDomain[0]) * 0.6
)}">${c}</span> ${i < all.length - 1 ? "vs" : ""}</h3>`;
};
if (attr === "Ganador") {
renderedCandidates = candidatesToCompare.map(renderCandidateTitle);
} else if (attr === "Igual Tamaño") {
renderedCandidates = "";
} else if (attr === "Total") {
renderedCandidates = "por puesto";
} else {
renderedCandidates = renderCandidateTitle(attr);
}
let mainHeader = "";
if (attr === "Ganador") {
if (candidatesToCompare.length >= 1) {
mainHeader = htl.html`<h2>¿En donde ganó?</h2>`;
} else if (candidatesToCompare.length === 1) {
mainHeader = htl.html`<h2>Total de Votos</h2>`;
} else {
mainHeader = htl.html`<h2>Seleccione al menos un candidato</h2>`;
}
} else {
if (attr === "Igual Tamaño") {
mainHeader = htl.html`<h2>Todos los puestos</h2>`;
} else {
mainHeader = htl.html`<h2>Total de Votos</h2>`;
}
}
return htl.html`<div id="title" style="position: absolute;
top: 20px;
left: 20px;
pointer-events: none;">${mainHeader} ${renderedCandidates}</div>`;
}