fix(ticker/pdf): ralentissement ticker à 18 car/s et correction troncature table PDF via truncateToWidth
This commit is contained in:
+1
-1
@@ -1684,7 +1684,7 @@ function updateTicker() {
|
||||
`⚠ ${x.r.region} — ${x.r.id_marche} : ${x.delai} jours restants`
|
||||
).join(' • ');
|
||||
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`;
|
||||
ticker.classList.add('active');
|
||||
document.body.classList.add('has-ticker');
|
||||
|
||||
@@ -91,6 +91,13 @@ function kpiBox(doc, x, y, w, h, label, value, color) {
|
||||
|
||||
// ─── 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 }) {
|
||||
const pageW = doc.page.width - 80;
|
||||
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');
|
||||
let x = 40;
|
||||
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];
|
||||
}
|
||||
y += 17;
|
||||
@@ -134,7 +141,7 @@ function table(doc, { title, headers, rows, colWidths }) {
|
||||
doc.fontSize(7).font('Helvetica');
|
||||
let x = 40;
|
||||
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];
|
||||
}
|
||||
stroke(doc, C.border);
|
||||
|
||||
Reference in New Issue
Block a user