Menu
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Enterprise
Open source
CircularVector class
Circular vector uses a single buffer to capture a stream of values overwriting the oldest value on add.
This supports adding to the ‘head’ or ’tail’ and will grow the buffer to match a configured capacity.
Signature
typescript
export declare class CircularVector<T = any> extends FunctionalVector<T> implements MutableVector<T>
Import
typescript
import { CircularVector } from '@grafana/data';
Constructors
Constructor | Modifiers | Description |
---|---|---|
constructor(options) | Constructs a new instance of the CircularVector class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
add | (value: T) => void | Add the value to the buffer | |
length | number |
Methods
Method | Modifiers | Description |
---|---|---|
get(index) | ||
reverse() | ||
set(index, value) | ||
setAppendMode(mode) | ||
setCapacity(v) | ||
toArray() | ||
toJSON() |
constructor(options)
Constructs a new instance of the CircularVector
class
Signature
typescript
constructor(options: CircularOptions<T>);
Parameters
Parameter | Type | Description |
---|---|---|
options | CircularOptions<T> |
add property
Add the value to the buffer
Signature
typescript
add: (value: T) => void;
length property
Signature
typescript
get length(): number;
get method
Signature
typescript
get(index: number): T;
Parameters
Parameter | Type | Description |
---|---|---|
index | number |
Returns:
T
reverse method
Signature
typescript
reverse(): void;
Returns:
void
set method
Signature
typescript
set(index: number, value: T): void;
Parameters
Parameter | Type | Description |
---|---|---|
index | number | |
value | T |
Returns:
void
setAppendMode method
Signature
typescript
setAppendMode(mode: 'head' | 'tail'): void;
Parameters
Parameter | Type | Description |
---|---|---|
mode | ‘head’ | ’tail’ |
Returns:
void
setCapacity method
Signature
typescript
setCapacity(v: number): void;
Parameters
Parameter | Type | Description |
---|---|---|
v | number |
Returns:
void
toArray method
Signature
typescript
toArray(): T[];
Returns:
T[]
toJSON method
Signature
typescript
toJSON(): T[];
Returns:
T[]
Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:

Getting started with the Grafana LGTM Stack
In this webinar, we’ll demo how to get started using the LGTM Stack: Loki for logs, Grafana for visualization, Tempo for traces, and Mimir for metrics.

Getting started with Grafana dashboard design (EMEA Timezone)
In this webinar, you'll learn how to design stylish and easily accessible Grafana dashboards that tell a story.

Unify your data with Grafana plugins: Datadog, Splunk, MongoDB, and more
In this webinar, learn how to leverage Grafana's plugin ecosystem for access to 80+ data sources, including plugins for Datadog, Splunk, MongoDB, and more.