Realtime Chart
The Realtime Chart smoothly visualizes data streaming in over time. It maintains a sliding window of data points and animates the line (and optional area fill) as new values arrive via the push() method. Ideal for live dashboards, server monitoring, and any scenario where data arrives continuously. Each series can show an area fill with configurable opacity, and the chart includes crosshair, grid, legend, and tooltips.
NOTE
For the full API, see the Charts API Reference.
Example
Usage
ts
import {
createRealtimeChart,
} from '@ripl/charts';
const chart = createRealtimeChart('#container', {
windowSize: 60,
transitionDuration: 200,
series: [
{ id: 'cpu',
label: 'CPU %',
showArea: true },
{ id: 'memory',
label: 'Memory %',
showArea: true },
],
});
// Push data as it arrives
setInterval(() => {
chart.push({
cpu: Math.random() * 100,
memory: Math.random() * 100,
});
}, 300);
// Clear the buffer
chart.clear();Options
series— Array of series withid,label, optionalcolor,lineType,lineWidth,showArea,areaOpacitywindowSize— Maximum visible data points (default60)transitionDuration— Transition duration per update in ms (default300)grid—boolean | ChartGridOptions— Show/configure grid lines (defaulttrue)crosshair—boolean | ChartCrosshairOptions— Show/configure crosshair (defaulttrue)tooltip—boolean | ChartTooltipOptions— Show/configure tooltipslegend—boolean | ChartLegendOptions— Show/configure legend (defaulttrue)axis—boolean | ChartAxisOptions— Configure axes (defaulttrue)yMin/yMax— Fixed Y axis bounds (auto-computed if omitted)padding— Chart padding
Methods
push(values)— Append a data point for each series. Keys must match seriesidvalues.clear()— Reset all buffers and clear the chart.update(options)— Update chart options (inherited fromChart).destroy()— Destroy the chart and release resources.