\Drupal\strata\Metrics MetricSeries

One line on a graph: a name, a unit, and a value per bucket.

Points are parallel to the timeline's buckets rather than sparse, so several series drawn on one chart share an x-axis by construction. A sparse series would need every consumer to reconcile indexes, and the first one to get it wrong would draw a line that is subtly out of step with the others.

The maximum is carried rather than recomputed by the renderer, because an SVG needs it to scale the y-axis before it draws the first point, and a renderer that walked the points twice would disagree with this one about an empty series.

Summary

Methods
Properties
Constants
__construct
max
min
latest
total
isFlat
count
jsonSerialize
key
label
points
unit
cumulative
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$key

$key : string

Type

string

$label

$label : string

Type

string

$points

$points : array

Type

array<string|int, mixed>

$unit

$unit : string

Type

string

$cumulative

$cumulative : bool

Type

bool

Methods

__construct()

__construct(string  $key, string  $label, list  $points = [], string  $unit = '', bool  $cumulative = false) : mixed

Constructs a series.

Parameters

string $key

Stable identifier, such as "stored_bytes".

string $label

Operator-facing name.

list $points

One value per bucket, oldest first.

string $unit

What the values are counted in.

bool $cumulative

TRUE when each point includes everything before it, which changes how a reader reads a fall.

Returns

mixed —

max()

max() : float

The largest value in the series.

Returns

float —

The maximum, or 0.0 for an empty series.

min()

min() : float

The smallest value in the series.

Returns

float —

The minimum, or 0.0 for an empty series.

latest()

latest() : float

The last value.

Returns

float —

The latest point, or 0.0 for an empty series.

total()

total() : float

The total across every point.

Returns

float —

The sum, which is only meaningful for a series that is not cumulative.

isFlat()

isFlat() : bool

Whether every point is zero.

Returns

bool —

TRUE when the series has nothing to draw.

count()

count() : int

How many points the series holds.

Returns

int —

The count.

jsonSerialize()

jsonSerialize() : array

{@inheritdoc}

Returns

array —