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.
<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.
// 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.
// 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.
// 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.
| Package | For |
|---|---|
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). |
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 --prereleaseriocharts-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:
dotnet add package RioCharts.Blazor --prereleaseThen in _Imports.razor:
@using RioCharts.Blazor
@using RioCharts.CoreStyles 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.
## 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.
Code
<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.
Code
<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.
Code
<RioChart TItem="double">
<LineSeries Name="Response time" Data="SeriesData.From(times, values)" StrokeWidth="1.25" />
</RioChart>How Blazor charts update
- Selectors run once per data change, never per render.
- A series reprocesses its data when
ItemsorDatais a new reference, orDataVersionchanges. Changing a list in place does not update the chart; assign a new list or bumpDataVersion. YValuereturnsdouble?;nullleaves a gap. Castdecimaltodouble.- 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.