mobile improvements mostly
This commit is contained in:
@@ -108,10 +108,9 @@ export async function downloadChartsPng(
|
||||
}
|
||||
if (row.length > 0) legendRows.push(row);
|
||||
}
|
||||
const headerHeight =
|
||||
(options.title ? 34 * dpr : 0) +
|
||||
(legendRows.length > 0 ? legendRows.length * rowHeight + 8 * dpr : 0);
|
||||
const totalHeight = headerHeight + canvases.reduce((sum, c) => sum + c.height, 0);
|
||||
const titleHeight = options.title ? 34 * dpr : 0;
|
||||
const legendHeight = legendRows.length > 0 ? legendRows.length * rowHeight + 8 * dpr : 0;
|
||||
const totalHeight = titleHeight + canvases.reduce((sum, c) => sum + c.height, 0) + legendHeight;
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = maxWidth;
|
||||
@@ -134,7 +133,12 @@ export async function downloadChartsPng(
|
||||
ctx.fillText(options.title, padding, 17 * dpr);
|
||||
y += 34 * dpr;
|
||||
}
|
||||
for (const c of canvases) {
|
||||
ctx.drawImage(c, 0, y);
|
||||
y += c.height;
|
||||
}
|
||||
if (legendRows.length > 0) {
|
||||
y += 8 * dpr;
|
||||
ctx.font = `${12 * dpr}px system-ui, -apple-system, sans-serif`;
|
||||
ctx.textBaseline = 'middle';
|
||||
for (const row of legendRows) {
|
||||
@@ -165,11 +169,6 @@ export async function downloadChartsPng(
|
||||
}
|
||||
y += rowHeight;
|
||||
}
|
||||
y += 8 * dpr;
|
||||
}
|
||||
for (const c of canvases) {
|
||||
ctx.drawImage(c, 0, y);
|
||||
y += c.height;
|
||||
}
|
||||
|
||||
triggerDownload(canvas.toDataURL('image/png'), `${fileName}.png`);
|
||||
|
||||
Reference in New Issue
Block a user