Axes and time
Axes are picked from the data: ticks fall on nice numbers or calendar boundaries, and labels follow the culture. A chart can have several y axes.
Time ticks that follow the range
Ticks land on calendar boundaries: midnights, Mondays, the 1st of the month, 1 January. The densest set whose labels fit is used, so a narrow chart gets fewer ticks.
Code
<RioChart Items="sessions" Title="Two days">
<LineSeries XValue="r => r.Time" YValue="r => r.Value" />
</RioChart>Two Y axes
Extra axes go on the right (or left, with Position = AxisPosition.Left); series pick one with YAxisId. Their ticks line up with the main grid. Several axes on one side sit side by side, each under its own title. SeriesColor = true colors the labels and title of an axis like its series, so it is clear which axis belongs to which line (or set Color). Here sessions per hour on the left and the orders they turn into on the right.
Code
<RioChart TItem="Reading" YAxis="@(new AxisOptions { Title = "Sessions per hour", SeriesColor = true })"
YAxes="@([new AxisOptions { Id = "orders", Title = "Orders", SeriesColor = true }])">
<BarSeries Items="orders" Name="Orders" XValue="r => r.Time" YValue="r => r.Value" YAxisId="orders" />
<LineSeries Items="sessions" Name="Sessions" XValue="r => r.Time" YValue="r => r.Value" />
</RioChart>Formats and fixed ranges
Set Format (any .NET format string) and Min/Max on an axis; Culture on the chart.
Code
<RioChart TItem="Sales" Culture="CultureInfo.GetCultureInfo("de-DE")"
YAxis="@(new AxisOptions { Title = "EUR", Format = "C0", Min = 0 })">
<BarSeries Items="quarters" Name="2026" XValue="s => s.Quarter" YValue="s => s.ThisYear" />
</RioChart>Labels from a function
When a format string is not enough, e.g. bytes that pick KB, MB or GB themselves, give the axis a LabelFormatter.
It writes the tick labels, and the tooltips and data labels of series without a Format of their own, so the values
can stay in bytes. Ticks stay on round steps. A series' Format falls back to its axis' format or function; the axis
never takes the series' format. For units of 1024, set TickBase = 1024 too: the steps are then round in KB, MB
or GB (20 MB, 40 MB) instead of round in bytes (47.7 MB, 95.4 MB).
Code
<RioChart Items="transfer" YAxis="@(new AxisOptions { Title = "Per hour", LabelFormatter = Bytes, TickBase = 1024 })">
<AreaSeries Name="Transferred" XValue="r => r.Time" YValue="r => r.Value" /> @* Value in bytes *@
</RioChart>
@code {
static string Bytes(double v)
{
string[] units = ["B", "KB", "MB", "GB", "TB"];
var unit = 0;
while (Math.Abs(v) >= 1024 && unit < units.Length - 1)
{
v /= 1024;
unit++;
}
return $"{v:0.#} {units[unit]}";
}
}Category labels
Category labels that do not fit side by side slope at 45 degrees, so every bar keeps its name; long names are shortened
with "…" (the tooltip has the full name). Set LabelRotation on the x axis for another angle (0 to 90), or
LabelRotation = 0 to keep them horizontal and show every n-th. In JSON definitions: "x": { "labelRotation": 45 }.
Code
@* Labels that do not fit slope at 45 degrees. XAxis="@(new AxisOptions { LabelRotation = 0 })" keeps them horizontal. *@
<RioChart Items="signupsByCountry">
<BarSeries Name="Sign-ups" XValue="c => c.Name" YValue="c => c.Value" Format="#,0" />
</RioChart>Logarithmic axis
For values that span several powers of ten, Scale = ScaleType.Log on a y axis gives equal ratios equal
distances: 10 to 100 is as tall as 100k to 1M. Here the visits per page in a month: on a linear axis the start page
flattens everything else, on a log axis every page can be read. Ticks are powers of ten (with 2 and 5 between them when
the range is short); bars start at the bottom of the axis. Zero and negative values have no place on a log axis: they
are left out, with a warning. In JSON definitions: "y": { "scale": "log" }.
Code
<RioChart Items="pageVisits" YAxis="@(new AxisOptions { Title = "Visits per month", Scale = ScaleType.Log })">
<BarSeries Name="Visits" XValue="p => p.Name" YValue="p => p.Value" Format="#,0" DataLabels="true" />
</RioChart>Logarithmic on both axes
The x axis takes Scale = ScaleType.Log too, for numbers under lines, areas and scatter points (bars need even
spacing, so their x axis stays linear, with a warning). Log on both axes, a power law such as load time against page size
becomes a straight line. Points at x zero or below are left out, x lines and bands are placed by ratio, and zoom and pan keep
ratios: drag to zoom, Shift-drag to pan. In JSON definitions: "x": { "scale": "log" }.
Code
<RioChart Items="pageLoads" Zoomable="true"
XAxis="@(new AxisOptions { Title = "Page size, kB", Scale = ScaleType.Log })"
YAxis="@(new AxisOptions { Title = "Load time, ms", Scale = ScaleType.Log })">
<ScatterSeries Name="Pages" XValue="p => p.SizeKb" YValue="p => p.Ms" Format="#,0 'ms'" />
</RioChart>Display time zone
By default times are shown exactly as given. With TimeZone ("UTC", "local" for the visitor's zone, or an IANA id),
times are plotted on instants and labelled in that zone, so a line runs straight through the repeated hour when summer time ends.
Tooltips show the offset when it differs from yours. TooltipFormat on the x axis sets the tooltip's time format
instead (e.g. "d MMM HH:mm", without seconds), with no offset added; the axis labels keep theirs.
Zone:
Code
<RioChart Items="orders" TimeZone="Europe/Stockholm"> @* Time is a DateTimeOffset *@
<LineSeries XValue="m => m.Time" YValue="m => m.Value" />
</RioChart>Time buckets in the display zone
With a TimeZone, Bucket groups on the calendar of that zone: a day runs from midnight to midnight there,
weeks start on Monday there, and a day with a daylight saving change is 23 or 25 hours long. The same orders, stored in UTC,
give other daily totals in New York or Tokyo. Without a zone, buckets use the times as given. JSON definitions do the same with
"timeZone" and "timeBucket".
Zone:
Code
<RioChart Items="orders" TimeZone="America/New_York"> @* Time is a DateTimeOffset in UTC *@
<BarSeries XValue="m => m.Time" YValue="m => m.Value" Bucket="TimeBucket.Day" Aggregate="Aggregate.Sum" />
</RioChart>