Syncfusion Blazor Chart SVG Export - Exported SVG Renders Incomplete/Clipped
When exporting a Syncfusion Blazor Chart as SVG using ExportAsync(ExportType.SVG, ...), the resulting SVG does not render the full chart as expected.
Only a portion of the chart is visible, and the exported SVG appears clipped or incomplete when rendered in a browser or embedded in an email.
Runnable Minimal Repro:
https://blazorplayground.syncfusion.com/LXVSDbCoGTsotJEQ
Steps to Reproduce:
1. Render the chart and click "Export Chart as SVG".
2. The exported SVG is displayed below the chart.
3. The SVG does not show the full chart; only a portion is visible.
Expected:
The exported SVG should render the entire chart, matching what is visible in the Blazor component.
Request:
Help me get this chart exported correctly in SVG format so that I can use it to send it in emails. The PNG export won't work for my case.
Thank you.
Repro code (for future reference):
Hi Ashish,
Thank you for reaching out.
We recommend normalizing the SVG before rendering by specifying the viewBox with appropriate width, height, and aspect ratio. This ensures consistent scaling and proper rendering across different screen sizes.
For your reference, we’ve attached the updated sample along with a screenshot demonstrating the changes.
|
@if (!string.IsNullOrEmpty(ExportedSvgMarkup)) { <h4>Exported SVG Output:</h4> <div id="exportedSvgContainer"> @((MarkupString)NormalizeSvg(ExportedSvgMarkup, 700, 500)) @* match your chart size *@ </div> }
@code { private string NormalizeSvg(string rawSvg, int w, int h) { // Remove any existing width/height that may be 0 or too small rawSvg = System.Text.RegularExpressions.Regex.Replace(rawSvg, @"\swidth=""[^""]*""", ""); rawSvg = System.Text.RegularExpressions.Regex.Replace(rawSvg, @"\sheight=""[^""]*""", "");
// Ensure a viewBox exists so the browser knows the intrinsic aspect ratio if (!System.Text.RegularExpressions.Regex.IsMatch(rawSvg, @"viewBox\s*=")) rawSvg = rawSvg.Replace("<svg", $"<svg viewBox='0 0 {w} {h}'");
// Give it an explicit size so it contributes to layout // (and don’t let it collapse) rawSvg = rawSvg.Replace( "<svg", $"<svg width='{w}' height='{h}' preserveAspectRatio='xMidYMid meet' style='display:block'");
return rawSvg; } } |
Sample : https://blazorplayground.syncfusion.com/BDByZPivKDaGaRdO
Please let us know if you have any concerns.
Regards,
Durga Gopalakrishnan.
- 2 Replies
- 2 Participants
-
AK Ashish Khanal
- Aug 15, 2025 08:39 PM UTC
- Aug 18, 2025 10:28 AM UTC