Skip to content

Commit

Permalink
fix: detect invalid/missing SVG charts due to no dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
EvHaus committed Jun 30, 2023
1 parent ed141c9 commit 0282ac5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ReactPDFChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ const getTspanChildrenOffsets = (node: TagElementType) => {
const webSvgToPdfSvg = (children: React.ReactElement, chartStyle?: Style) => {
const svgString = renderToStaticMarkup(children);

if (!svgString?.length) {
throw new Error(
`<ReactPDFChart /> was unable to convert your chart into static markup. The most common reason for this is that your chart is missing a "height" or "width". If you think it's a different problem, please report this issue.`,
);
}

const htmlReactParserOptions: HTMLReactParserOptions = {
replace: replaceHtmlWithPdfSvg,
};
Expand Down

0 comments on commit 0282ac5

Please sign in to comment.