Server-side export
Render charts to PNG or SVG on the server in .NET. RioCharts.Skia draws the same chart model and layout as the Blazor
components, with real font metrics. Use it for emails, reports, Teams or Slack messages, and AI agents.
dotnet add package RioCharts.Skia --prereleaseOn Linux it uses SkiaSharp's native assets without system dependencies; install a font package in slim containers (see FontFamily below).
var spec = new ChartDefinition
{
Title = "Orders per day",
Y = new AxisOptions { Title = "Orders" },
Series = [new SeriesOptions { Id = "orders", Name = "Orders", Curve = CurveType.Monotone }],
Annotations = [new Annotation { Value = 250, Label = "Target" }],
};
var data = new Dictionary<string, SeriesData> { ["orders"] = SeriesData.From(days, orders) };
byte[] png = ChartExport.ToPng(spec, data, new ExportOptions { Width = 640, Height = 320, Theme = ExportTheme.Dark });
string svg = ChartExport.ToSvg(spec, data);
// In a minimal API:
app.MapGet("/charts/orders.png", () => Results.File(ChartExport.ToPng(spec, data), "image/png"));Options
| Option | Default | Meaning |
|---|---|---|
Width, Height | 800 × 400 | Chart size in pixels. |
Scale | 2 | Pixel density of the PNG (2 = sharp on high-density screens). |
Theme | ExportTheme.Light | Or Dark; .With("--rio-series-1", "#0b6e4f") overrides a token. |
Background | the surface color | Null for a transparent PNG. |
FontFamily | Segoe UI, Inter, Roboto, ... | The first installed font is used. In Linux containers install fonts (e.g. fonts-dejavu). |
CssVariables | false | SVG only: write colors as var(--rio-…, color) so a page can restyle it. |
Charts made with components export in the browser with
chart.ExportPngAsync() and chart.ExportSvgAsync(); or serialize chart.GetDefinition() and render it here later.