Clicks and selection

Handle clicks on points, bars and legend items, and let people select points or a range, with events in .NET. Clicks and selections call back into .NET once, when they happen; hover feedback stays in the browser.

Point clicks

Click a point to get its item in OnPointClick, with the series it belongs to.

What counts as a click on a point: on lines, areas and scatter charts, a click within 16 px of a point, so a click on a line next to a point picks that point; with several series the closest point wins, and a click on a line between two points far apart picks nothing. On bars, anywhere on the bar (box plots and candlesticks: anywhere in their slot); on pies, heatmaps, treemaps and calendars, the slice or cell. A point wins over a reference line or band underneath, but not over a point annotation or callout (see Annotations).

Chart with 2 series. Web: 192 values, lowest 28 sessions at 11/17/2026 7:45 AM, highest 252 sessions at 11/16/2026 8:00 PM, trend stable. App: 192 values, lowest 13 sessions at 11/16/2026 7:45 AM, highest 165 sessions at 11/17/2026 7:45 PM, trend rising. 0100200300Nov 166:00 AM12:00 PM6:00 PMNov 176:00 AM12:00 PM6:00 PMSessions per 15 minWebAppUse Left and Right to move between points, Up and Down to change series. Press Enter to select a point, Escape to leave.

Clicked: nothing yet

Code
Razor
<RioChart TItem="Reading" OnPointClick="e => clicked = e">
    <LineSeries Items="web" Name="Web" XValue="r => r.Time" YValue="r => r.Value" Format="#,0 'sessions'" />
    <LineSeries Items="app" Name="App" XValue="r => r.Time" YValue="r => r.Value" Format="#,0 'sessions'" />
</RioChart>

<p>@clicked?.SeriesName @clicked?.Item?.Value sessions at @clicked?.Item?.Time</p>

Legend toggles

Hover or focus a legend item for a summary of its series (range, last value, trend; for slices the value and share). Click it to hide the series; @bind-HiddenSeries keeps the hidden series in your page.

Chart with 2 series. Web: 192 values, lowest 28 sessions at 11/17/2026 7:45 AM, highest 252 sessions at 11/16/2026 8:00 PM, trend stable. App: 192 values, lowest 13 sessions at 11/16/2026 7:45 AM, highest 165 sessions at 11/17/2026 7:45 PM, trend rising. 0100200300Nov 166:00 AM12:00 PM6:00 PMNov 176:00 AM12:00 PM6:00 PMSessions per 15 minWebAppUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.

Hidden: none.

Code
Razor
<RioChart TItem="Reading" @bind-HiddenSeries="hidden">
    <LineSeries Items="web" Name="Web" XValue="r => r.Time" YValue="r => r.Value" Format="#,0 'sessions'" />
    <LineSeries Items="app" Name="App" XValue="r => r.Time" YValue="r => r.Value" Format="#,0 'sessions'" />
</RioChart>

<p>Hidden: @string.Join(", ", hidden)</p>

Highlight and show series from code

Hover or focus a legend item, or one of the buttons below the chart, to fade the other series: HighlightSeriesAsync(id). Here OnLegendClicking cancels the usual toggle and shows only the clicked series instead, with ShowSeriesAsync/HideSeriesAsync inside ApplyAsync so the chart draws once.

Chart with 3 series. Search: 192 values, lowest 15 at 11/16/2026 7:15 AM, highest 141 at 11/16/2026 8:00 PM, trend rising. Social: 192 values, lowest 2 at 11/16/2026 6:30 AM, highest 89 at 11/17/2026 8:00 PM, trend rising. Email: 192 values, lowest 7 at 11/16/2026 6:00 AM, highest 58 at 11/16/2026 9:45 AM, trend stable. 050100150Nov 166:00 AM12:00 PM6:00 PMNov 176:00 AM12:00 PM6:00 PMSessions per 15 minSearchSocialEmailUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.

Code
Razor
<RioChart @ref="chart" TItem="Reading" OnLegendClicking="ShowOnly">
    <LineSeries Id="search" Items="search" Name="Search" ... />
    <LineSeries Id="social" Items="social" Name="Social" ... />
    <LineSeries Id="email" Items="email" Name="Email" ... />
</RioChart>

<button @onmouseenter="() => chart.HighlightSeriesAsync("social")"
        @onmouseleave="() => chart.HighlightSeriesAsync(null)">Social</button>

@code {
    async Task ShowOnly(LegendClickingEventArgs e)
    {
        e.Cancel = true; // instead of toggling: show only the clicked series
        await chart.ApplyAsync(async () =>
        {
            foreach (var id in ids)
                await (id == e.SeriesId ? chart.ShowSeriesAsync(id) : chart.HideSeriesAsync(id));
        });
    }
}

Selecting a range

Selection="ChartSelectionMode.Range": drag across the plot to select a range, click to clear it. Bind @bind-SelectedRange and @bind-SelectedItems, or handle OnSelectionChanged. A range selects the items of the visible series inside it.

Chart with 1 series. Web: 192 values, lowest 28 at 11/17/2026 7:45 AM, highest 252 at 11/16/2026 8:00 PM, trend stable. 0100200300Nov 166:00 AM12:00 PM6:00 PMNov 176:00 AM12:00 PM6:00 PMSessions per 15 minUse Left and Right to move between points. Press Escape to leave.

Drag across the chart to select a range.

Code
Razor
<RioChart TItem="Reading" Selection="ChartSelectionMode.Range" @bind-SelectedRange="range" @bind-SelectedItems="readings">
    <LineSeries Items="web" Name="Web" XValue="r => r.Time" YValue="r => r.Value" />
</RioChart>

<p>@readings.Count readings, @readings.Sum(r => r.Value) sessions</p>

Selecting points

Selection="ChartSelectionMode.Points": click a point or bar to select it, Ctrl/⌘ or Shift+click to add or remove one, click beside the points to clear. @bind-SelectedItems gets the items behind the selected points.

Chart with 1 series. Handling time: 4 values, lowest 20 at Account, highest 250 at Payment. 0100200300ShippingPaymentReturnsAccountminUse Left and Right to move between points. Press Escape to leave.

Click a bar to see its tickets.

Code
Razor
<RioChart TItem="Ticket" Items="tickets" Selection="ChartSelectionMode.Points" @bind-SelectedItems="selected">
    <BarSeries Name="Handling time" XValue="t => t.Topic" YValue="t => t.Minutes" Aggregate="Aggregate.Sum" />
</RioChart>

<p>@string.Join(", ", selected.Select(t => t.Subject))</p>

Selection on any chart

Horizontal bars, box plots and waterfalls, heatmap cells, pie and donut slices and radial bars show their selection too, as an outline. Here two charts bind the same SelectedItems: select a topic in either and both outline it. The grouped "Other" slice holds several items and is not outlined.

Chart with 1 series. Handling time: 4 values, lowest 20 at Account, highest 250 at Payment. 0100200300minShippingPaymentReturnsAccountUse Left and Right to move between points. Press Escape to leave.
Donut chart with 4 items: Shipping 155, Payment 250, Returns 105, Account 20. ShippingPaymentReturnsAccount47%530Total29%4%20%Use the arrow keys to move between slices. Press Escape to leave.

Click a bar or a slice.

Code
Razor
<RioChart TItem="Ticket" Items="tickets" Horizontal="true" Selection="ChartSelectionMode.Points" @bind-SelectedItems="selected">
    <BarSeries Name="Handling time" XValue="t => t.Topic" YValue="t => t.Minutes" Aggregate="Aggregate.Sum" />
</RioChart>
<RioChart TItem="Ticket" Items="tickets" Selection="ChartSelectionMode.Points" @bind-SelectedItems="selected">
    <DonutSeries Name="Handling time" XValue="t => t.Topic" YValue="t => t.Minutes" Aggregate="Aggregate.Sum" />
</RioChart>

From code

Everything the user can do has an API: take a reference with @ref and call SelectItemsAsync, SelectRangeAsync, ClearSelectionAsync, GetItemsInRange, ShowSeriesAsync, HideSeriesAsync, ToggleSeriesAsync, HighlightSeriesAsync or Refresh. ApplyAsync(async () => …) groups several of them into one redraw. OnLegendClicking can change or cancel what the user did. Zooming has its own API, on Zoom and pan.

To place your own elements over a chart, ValueToPixel(x, y) gives the position of a data value in CSS pixels from the chart's top left corner, and PixelToValue(x, y) the value at a position. Layout exposes the scales and the hit-test index.

An unhandled error has occurred. Reload 🗙