From a175d11492a35491044b5c17031624e52497e8cc Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 8 Aug 2025 17:36:30 -0600 Subject: [PATCH] existing stlye update --- .../elements/MetricElement/MetricContent.tsx | 5 +++-- .../useReportPageExport.tsx | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/ui/report/elements/MetricElement/MetricContent.tsx b/apps/web/src/components/ui/report/elements/MetricElement/MetricContent.tsx index 688e7734e..052da8b4b 100644 --- a/apps/web/src/components/ui/report/elements/MetricElement/MetricContent.tsx +++ b/apps/web/src/components/ui/report/elements/MetricElement/MetricContent.tsx @@ -24,9 +24,9 @@ export const MetricContent = React.memo( const ref = useRef(null); const [inViewport] = useInViewport(ref, { - threshold: isExportMode ? 0 : 0.33 + threshold: 0.33 }); - const renderChart = inViewport; + const renderChart = inViewport || isExportMode; const { data: metric, @@ -72,6 +72,7 @@ export const MetricContent = React.memo( return ( @@ -63,10 +66,11 @@ export const useReportPageExport = ({ const buildHtmlMethod = useMemoizedFn(async (node: HTMLElement, title: string) => { try { + await timeout(150); //wait for chart nodes to be rendered const result = await buildExportHtml({ root: node, title }); printHTMLPage({ html: result, filename: title, closeOnPrint: false }); } finally { - setIsExportingReport(false); + // setIsExportingReport(false); } }); @@ -156,6 +160,13 @@ const buildExportHtml = async (options?: { clone.removeAttribute('spellcheck'); } + // Ensure the cloned root has no padding and full width + const existingStyle = clonedRoot.getAttribute('style') || ''; + clonedRoot.setAttribute( + 'style', + `${existingStyle}; width: 100%; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: visible;`.trim() + ); + // Wrap content with a fixed width, centered container for consistency const wrapper = document.createElement('div'); wrapper.setAttribute(