Getting started

RioCharts draws the same chart in a Blazor app, as PNG or SVG on the server, from a JSON definition, or from an AI agent. Pick where you start; the chart model is the same everywhere.

Choose your starting point

In a Blazor app

Interactive charts with tooltips, zoom and keyboard access, in Server, WebAssembly, Auto, static rendering or MAUI Blazor Hybrid. Add RioCharts.Blazor, @using RioCharts.Blazor and @using RioCharts.Core, and a chart; the Blazor section below goes on from there.

Razor
<RioChart Items="orders">
    <LineSeries XValue="r => r.Time" YValue="r => r.Value" />
</RioChart>

Images on the server

PNG and SVG from a background job, an API endpoint or a report, with no browser. Add RioCharts.Skia, describe the chart with a ChartDefinition and pass the data as columns. See Server-side export.

C#
// dotnet add package RioCharts.Skia --prerelease
var chart = new ChartDefinition
{
    Title = "Orders per day",
    Series = [new SeriesOptions { Id = "orders", Name = "Orders" }],   // a line, unless Type says otherwise
};
var data = new Dictionary<string, SeriesData> { ["orders"] = SeriesData.From(days, orders) };

byte[] png = ChartExport.ToPng(chart, data, new ExportOptions { Width = 640, Height = 320 });
string svg = ChartExport.ToSvg(chart, data);

From JSON

Save charts as JSON, let users edit them, or store them with a dashboard. A definition names a dataset and its fields; it renders in Blazor with <RioChart Definition Datasets> and on the server with RioCharts.Skia. See chart definitions, or try the editor.

C#
// RioCharts.Core reads and binds definitions; using RioCharts.Core.Definitions
var json = """{"dataset":"sales","series":[{"type":"bar","x":"month","y":"revenue"}]}""";
var datasets = new Dictionary<string, ChartDataset>
{
    ["sales"] = ChartDataset.FromCsv("sales", File.ReadAllText("sales.csv")),
};

var definition = ChartDefinitionJson.Parse(json).Definition!;

// In Blazor:  <RioChart Definition="definition" Datasets="datasets" />
// On the server, with RioCharts.Skia:
var bound = ChartDefinitionBinder.Bind(definition, datasets);
byte[] png = ChartExport.ToPng(bound.Definition, bound.Data);

From AI agents

Let a model chart your data: RioCharts.AI gives your own agent create_chart and render_chart tools (Microsoft.Extensions.AI or MCP), and riocharts-mcp lets local agents such as Claude Code or Copilot chart CSV and JSON files. See AI agents and MCP.

C#
// Your own agent: dotnet add package RioCharts.AI --prerelease
var tool = new ChartTool(new InMemoryDataSource([shop]));
var response = await chatClient.GetResponseAsync("Chart orders per channel this week",
    new ChatOptions { Tools = tool.AsAIFunctions() });

// Local agents (Claude Code, Copilot, ...): a .NET tool that charts CSV and JSON files
// dotnet tool install -g RioCharts.Mcp --prerelease
// .mcp.json: { "mcpServers": { "riocharts": { "command": "riocharts-mcp", "args": ["--data", "data"] } } }

Packages

RioCharts is on NuGet. Take the parts you need; each brings in what it depends on. The packages are release candidates until 1.0, so add --prerelease (or tick Include prerelease in Visual Studio). All target .NET 10 (LTS) and .NET 11; riocharts-mcp runs on either.

PackageFor
RioCharts.Core The chart engine alone, with no UI dependencies.
RioCharts.Blazor The <RioChart> component for Blazor apps.
RioCharts.Skia PNG and SVG export on the server.
RioCharts.AI create_chart and render_chart tools for AI agents.
RioCharts.Mcp riocharts-mcp, a local MCP server for agents (a .NET tool).
Terminal
dotnet add package RioCharts.Core --prerelease
dotnet add package RioCharts.Blazor --prerelease
dotnet add package RioCharts.Skia --prerelease
dotnet add package RioCharts.AI --prerelease
dotnet tool install -g RioCharts.Mcp --prerelease

riocharts-mcp is a .NET tool rather than a library; see AI agents and MCP. Update it with dotnet tool update -g RioCharts.Mcp --prerelease.

Blazor apps

For Blazor (Server, WebAssembly, Auto or MAUI Blazor Hybrid), add one package:

Terminal
dotnet add package RioCharts.Blazor --prerelease

Then in _Imports.razor:

Razor
@using RioCharts.Blazor
@using RioCharts.Core

Styles come with your app's {App}.styles.css bundle automatically; there is nothing else to register. Zero configuration gives a finished chart.

Using a coding agent

Models do not know RioCharts yet. Paste this into your repository's AGENTS.md (or CLAUDE.md, .github/copilot-instructions.md) so the agent reads the guide before it writes chart code. llms-full.txt has setup, rules, examples and every parameter in one file; see also coding agents and MCP.

Markdown
## Charts

Charts use RioCharts.Blazor (1.0 release candidate, .NET 10 and 11). Before writing chart code, read
https://riocharts.com/llms-full.txt, or call get_usage if the riocharts MCP server is set up.

- Setup: the RioCharts.Blazor package, and `@using RioCharts.Blazor` and `@using RioCharts.Core` in `_Imports.razor`. Nothing to register.
- Set `TItem` on `<RioChart>` when it has event handlers (`OnPointClick`, ...).
- A chart updates when `Items` is a new list or `DataVersion` changes, not when a list is changed in place.
- Tooltips, zoom and clicks need an interactive render mode on the page.

Your first chart

Pass items and say which property is x and which is y. The axis type follows the data: times give a time axis, numbers a linear axis, strings a category axis.

Chart with 1 series. series-1: 35 values, lowest 159 at 11/2/2026 12:00 AM, highest 290 at 10/18/2026 12:00 AM, trend falling. 150200250300Oct 19Oct 26Nov 2Nov 9Nov 16Use Left and Right to move between points. Press Escape to leave.
Code
Razor
<RioChart Items="orders">
    <LineSeries XValue="r => r.Time" YValue="r => r.Value" />
</RioChart>

@code {
    record Reading(DateTime Time, double? Value);
    List<Reading> orders = ...; // orders per day
}

Several series

More series add a legend. Click a legend item to hide a series; the axis refits and colors stay put.

Chart with 2 series. Web: 192 values, lowest 28 at 11/17/2026 7:45 AM, highest 252 at 11/16/2026 8:00 PM, trend stable. App: 192 values, lowest 13 at 11/16/2026 7:45 AM, highest 165 at 11/17/2026 7:45 PM, trend rising. 0100200300Nov 166:00 AM12:00 PM6:00 PMNov 176:00 AM12:00 PM6:00 PMSessionsWebAppUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<RioChart TItem="Reading" YAxis="@(new AxisOptions { Title = "Sessions" })">
    <LineSeries Items="web" Name="Web" XValue="r => r.Time" YValue="r => r.Value" />
    <LineSeries Items="app" Name="App" XValue="r => r.Time" YValue="r => r.Value" />
</RioChart>

Arrays instead of items

For large data, pass columns directly with SeriesData.From: no per-item cost. The chart then needs some TItem, e.g. double.

Chart with 1 series. Response time: 20000 values, lowest 171.7 at 10/17/2026 12:03 AM, highest 453.9 at 10/18/2026 11:18 AM, trend rising. 100200300400500Oct 1712:00 PMOct 1812:00 PMOct 1912:00 PMOct 20Use Left and Right to move between points. Press Escape to leave.
Code
Razor
<RioChart TItem="double">
    <LineSeries Name="Response time" Data="SeriesData.From(times, values)" StrokeWidth="1.25" />
</RioChart>

Shared defaults

Settings that every chart in the app shares (culture, time zone, height, legend, axes) go in a RioChartDefaults instead of on each chart. Register it once in Program.cs with AddRioCharts; that reaches every chart, whatever its render mode. Nothing else needs registering, and without it charts use their built-in defaults.

To give part of the app other defaults, cascade a RioChartDefaults around it: each setting comes from the chart itself, else the cascade, else the registered defaults. A cascade without IsFixed can be replaced at runtime, e.g. on a language switch, and the charts follow. A cascade does not reach into components with another render mode, so prefer AddRioCharts for app-wide settings. A chart's YAxis replaces the default axis as a whole. Here both charts get the Swedish culture, 200 px and a legend at the bottom.

Diagram "Sessions" med 2 serier. Web: 192 värden, lägst 28 vid 2026-11-17 07:45, högst 252 vid 2026-11-16 20:00, stabil trend. App: 192 värden, lägst 13 vid 2026-11-16 07:45, högst 165 vid 2026-11-17 19:45, stigande trend. Sessions020040016 nov.06:0012:0018:0017 nov.06:0012:0018:00WebAppAnvänd vänster- och högerpil för att flytta mellan punkter, upp- och nedpil för att byta serie. Tryck Escape för att lämna.
Diagram "Sessions, total" med 2 serier. Web: 192 värden, lägst 28 vid 2026-11-17 07:45, högst 252 vid 2026-11-16 20:00, stabil trend. App: 192 värden, lägst 13 vid 2026-11-16 07:45, högst 165 vid 2026-11-17 19:45, stigande trend. Sessions, total050016 nov.06:0012:0018:0017 nov.06:0012:0018:00TotalWebAppAnvänd vänster- och högerpil för att flytta mellan punkter, upp- och nedpil för att byta serie. Tryck Escape för att lämna.
Code
Razor
// Program.cs: every chart in the app gets these (optional; works in every render mode)
builder.Services.AddRioCharts(new RioChartDefaults
{
    Culture = CultureInfo.GetCultureInfo("sv-SE"),
    TimeZone = "Europe/Stockholm",
    Height = 200,
    Legend = new LegendOptions { Position = LegendPosition.Bottom },
    YAxis = new AxisOptions { Format = "#,0" },
});

@* A section with other defaults: cascade them (each setting falls back to the registered ones) *@
<CascadingValue Value="@(new RioChartDefaults { Height = 400 })" IsFixed="true">
    ...
</CascadingValue>

@* A page: its own YAxis wins (with keeps the default's other settings) *@
@inject RioChartDefaults ChartDefaults
<RioChart TItem="Reading" YAxis="@(ChartDefaults.YAxis! with { Title = "Total" })"> ... </RioChart>

How Blazor charts update

  • Selectors run once per data change, never per render.
  • A series reprocesses its data when Items or Data is a new reference, or DataVersion changes. Changing a list in place does not update the chart; assign a new list or bump DataVersion.
  • YValue returns double?; null leaves a gap. Cast decimal to double.
  • The chart fills its container's width and is 300 px high by default (Height).

Blazor render modes

  • Interactive pages (Server, WebAssembly or Auto) get everything: tooltips, zoom, keyboard navigation and downloads.
  • Static server rendering and prerendering draw the chart as plain SVG, with no JS. It is laid out at Width (or 640 px) and scales to its container. Tooltips, the download button and keyboard navigation appear once the page is interactive. Canvas series are drawn as SVG until then, so the prerendered chart is never blank.
  • .NET MAUI Blazor Hybrid (dotnet new maui-blazor): the same package and usings, nothing else. The chart runs in the app's WebView and is always interactive. Tooltips, zoom, clicks and the PNG download work on Windows; Android and iOS have not been tested yet.

Trimming and native AOT

Every package is marked AOT-compatible and publishes without trimming warnings. JSON definitions use source-generated serialization, so Blazor WebAssembly, trimmed servers and native AOT apps (also with Skia export and the AI tools) work as they do in development. Read definitions with ChartDefinitionJson.Parse; it fills in defaults that the generated serializer cannot.

An unhandled error has occurred. Reload 🗙