The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/docs/sources/packages_api/data/circularvector.md

3.4 KiB

+++

-----------------------------------------------------------------------

Do not edit this file. It is automatically generated by API Documenter.

-----------------------------------------------------------------------

title = "CircularVector" keywords = ["grafana","documentation","sdk","@grafana/data"] type = "docs" +++

CircularVector class

Circular vector uses a single buffer to capture a stream of values overwriting the oldest value on add.

This supports addting to the 'head' or 'tail' and will grow the buffer to match a configured capacity.

Signature

export declare class CircularVector<T = any> extends FunctionalVector implements MutableVector<T> 

Import

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

constructor(options: CircularOptions<T>);

Parameters

Parameter Type Description
options CircularOptions<T>

add property

Add the value to the buffer

Signature

add: (value: T) => void;

length property

Signature

get length(): number;

get method

Signature

get(index: number): T;

Parameters

Parameter Type Description
index number

Returns:

T

reverse method

Signature

reverse(): void;

Returns:

void

set method

Signature

set(index: number, value: T): void;

Parameters

Parameter Type Description
index number
value T

Returns:

void

setAppendMode method

Signature

setAppendMode(mode: 'head' | 'tail'): void;

Parameters

Parameter Type Description
mode 'head' | 'tail'

Returns:

void

setCapacity method

Signature

setCapacity(v: number): void;

Parameters

Parameter Type Description
v number

Returns:

void

toArray method

Signature

toArray(): T[];

Returns:

T[]

toJSON method

Signature

toJSON(): T[];

Returns:

T[]