Data JS behaviour

Metric chart

A chart with metric tabs: the line morphs into the new series and the headline rolls; deltas take the right colour (and flip for inverse metrics).

Real scenarios

The component as it is used in a product — not a specimen grid.

Workspace health

Twelve months, three metrics on tabs: the line morphs into the new series and the headline rolls. Watch latency — a falling line is good there, so invertDelta flips the delta’s colour.

Workspace health

$52,350 +12.4% vs last month
Workspace health
RevenueActive usersLatency
Oct$32,0009,304250 millisecond
Nov$34,5899,302238 millisecond
Dec$37,1719,809228 millisecond
Jan$40,74110,317222 millisecond
Feb$41,39910,268216 millisecond
Mar$43,52810,421210 millisecond
Apr$45,66110,660204 millisecond
May$46,18511,070198 millisecond
Jun$47,29411,480192 millisecond
Jul$48,65011,890186 millisecond
Aug$50,50012,300182 millisecond
Sep$52,35012,710187 millisecond

One metric, opening on it

active picks the starting tab; height tunes the plot — a half-height card for a sidebar widget.

Tickets resolved

1,311 +6.9%
Tickets resolved
OpenedResolved
Oct934922
Nov1,0101,036
Dec1,1311,027
Jan1,1181,079
Feb1,1731,132
Mar1,2281,117
Apr1,2091,127
May1,2171,147
Jun1,2361,188
Jul1,2781,229
Aug1,3201,270
Sep1,3621,311

Important props

Important props
Prop Type Default What it does
labels / metrics array [] Each metric: ['id' => …, 'label' => …, 'values' => […], 'delta' => 12.4, 'format' => [Intl NumberFormat options], 'invertDelta' => true] — as many values as labels.
active string null The metric tab that starts selected.
title / subtitle / caption string null The title, subtitle and the caption beside the headline.
height int 200 The plot height.

Snippet

<x-nx::metric-chart title="سلامت ورک‌اسپیس" caption="نسبت به ماه پیش" :labels="$months" :metrics="[
    ['id' => 'revenue', 'label' => 'درآمد', 'values' => $values, 'delta' => 12.4],
]" />