fix(ticker/pdf): ralentissement ticker à 18 car/s et correction troncature table PDF via truncateToWidth

This commit is contained in:
2026-08-21 22:35:46 +01:00
parent dd0279ad09
commit 7599b98959
2 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -1684,7 +1684,7 @@ function updateTicker() {
`${x.r.region}${x.r.id_marche} : ${x.delai} jours restants` `${x.r.region}${x.r.id_marche} : ${x.delai} jours restants`
).join(' • '); ).join(' • ');
content.textContent = text; content.textContent = text;
const duration = Math.min(70, Math.max(25, Math.ceil(text.length / 14))); const duration = Math.min(100, Math.max(30, Math.ceil(text.length / 18)));
content.style.animationDuration = `${duration}s`; content.style.animationDuration = `${duration}s`;
ticker.classList.add('active'); ticker.classList.add('active');
document.body.classList.add('has-ticker'); document.body.classList.add('has-ticker');
+9 -2
View File
@@ -91,6 +91,13 @@ function kpiBox(doc, x, y, w, h, label, value, color) {
// ─── Table ──────────────────────────────────────────────────────────────────── // ─── Table ────────────────────────────────────────────────────────────────────
function truncateToWidth(doc, text, maxWidth) {
if (doc.widthOfString(text) <= maxWidth) return text;
let t = text;
while (t.length > 1 && doc.widthOfString(t + '…') > maxWidth) t = t.slice(0, -1);
return t + '…';
}
function table(doc, { title, headers, rows, colWidths }) { function table(doc, { title, headers, rows, colWidths }) {
const pageW = doc.page.width - 80; const pageW = doc.page.width - 80;
const totalW = colWidths.reduce((a, b) => a + b, 0); const totalW = colWidths.reduce((a, b) => a + b, 0);
@@ -111,7 +118,7 @@ function table(doc, { title, headers, rows, colWidths }) {
doc.fontSize(7.5).font('Helvetica-Bold'); doc.fontSize(7.5).font('Helvetica-Bold');
let x = 40; let x = 40;
for (let i = 0; i < headers.length; i++) { for (let i = 0; i < headers.length; i++) {
doc.text(headers[i], x + 3, y + 4, { width: widths[i] - 6, height: 11, ellipsis: true }); doc.text(truncateToWidth(doc, headers[i], widths[i] - 6), x + 3, y + 4, { width: widths[i] - 6, lineBreak: false });
x += widths[i]; x += widths[i];
} }
y += 17; y += 17;
@@ -134,7 +141,7 @@ function table(doc, { title, headers, rows, colWidths }) {
doc.fontSize(7).font('Helvetica'); doc.fontSize(7).font('Helvetica');
let x = 40; let x = 40;
for (let i = 0; i < row.length; i++) { for (let i = 0; i < row.length; i++) {
doc.text(String(row[i] ?? '—'), x + 3, y + 4, { width: widths[i] - 6, height: rowH - 4, ellipsis: true }); doc.text(truncateToWidth(doc, String(row[i] ?? '—'), widths[i] - 6), x + 3, y + 4, { width: widths[i] - 6, lineBreak: false });
x += widths[i]; x += widths[i];
} }
stroke(doc, C.border); stroke(doc, C.border);