Live data
Real-time charts in Blazor: append points to a SeriesBuffer from any thread. The chart coalesces the changes and redraws at
most every RefreshInterval milliseconds; the tooltip stays open while it updates.
A two-minute window
Visitors on the store right now, web and app: two buffers with a time window, fed four times a second.
Use Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
<RioChart TItem="double" RefreshInterval="250">
<LineSeries Name="Web" Buffer="web" Curve="CurveType.Monotone" />
<LineSeries Name="App" Buffer="app" Curve="CurveType.Monotone" />
</RioChart>
@code {
SeriesBuffer web = new(timeWindow: TimeSpan.FromMinutes(2));
SeriesBuffer app = new(timeWindow: TimeSpan.FromMinutes(2));
void OnVisitors(DateTime time, double count) => web.Append(time, count); // any thread
}From a stream
await buffer.ConsumeAsync(analytics.VisitorsAsync(token), v => v.Time, v => v.Count, token);Buffers keep at most Capacity points (100 000 by default) and, with a timeWindow, only the latest span of time.