Skip to main content

RealtimeChart

RealtimeChart is a React component for rendering timeseries-based data in realtime chart format.

When?#

Use RealtimeChart (over TimeseriesChart) for more arbitrary form of data, you want a finer control of the updates timing.

Usage#

<RealtimeChart
width="100%"
currentTime={time}
onClick={(evt, time) => console.log(`Maps to ${time} here!`)}
rows={buckets}
renderRow={(bucket, Row) => {
return (
<Row start={bucket.start} end={bucket.end}>
{bucket.data}
</Row>
);
}}
/>

RealtimeChart will re-render every time you pass new values to currentTime or rows props, giving you the realtime update effect. You need to transform your data to the format that rows expects: Bucket[]

Props#

PropTypeRequiredDefaultDescription
widthnumber or stringNo'100%'The width of the chart. If given in number, the width is set in px. If given in string, it tries to parse into %, relative to the parent element.
renderRowRenderRowFuncYes-The function which formats the row. It's passed a bucket and the Row React component. Must return a JSX which is up to you to format and render as you like.
onClick(MouseEvent, number) => voidNo() => {}The function that gets triggered when user clicks on the chart. It gets reference to the MouseEvent which triggered this function, and a number representing the time within the chart (mapped by the position within the chart).
onFrameChange({ start: number, end: number }) => voidNo() => {}Executed when the chart's timeframe changes. Timeframe changes when the chart's boundary is recaulculated and re-rendered. The start and end passed are the new timeframe's start and end time.
renderNoDataFallback() => ReactElementNo() => <div>Waiting for data...</div>The function that returns a JSX when newBucket prop is undefined.
containerClassstringNo""A list of HTML class names for the chart's container.
containerStyleObjectNo{}An object of React inline styles for the chart's container.
optionsOptionsNo{}Refer to the Options section below.

Options#

PropTypeRequiredDefaultDescription
frameCyclenumberNo60000The length of the time frame lifecycle in milliseconds, where one time frame represents the period that chart remains with the same time range between updates.
rulerIntervalnumberNo5000The time interval between each ruler. Not applicable if hideRuler option is true.
hideRulerbooleanNofalseIf true, hide the ruler (see the image below).
hideSeekerbooleanNofalseIf true, hide the seeker (see the image below).
hideTrackerbooleanNofalseIf true, hide the tracker (the vertical line which tracks the mouse position - see the image below).
hideTrackerTooltipbooleanNofalseIf true, hide the tooltip for the tracker.
formatRulerInterval(number) => stringNo(pos: number) => "" + posFormats the time label shown for the rulers and tracker tooltip.