Components/MotionMetric

MotionMetric

Caller-driven metric cards, charts, and composite dashboards.

VerifiedSince 0.7.0

Usage

All Variants

Each entry in periods carries its own data; v-model:period switches between them.

Loading demo...

Best Practices

  • Give every period real data and handle update events when controlled; don't relabel a button over the same series.
  • The caller owns timer remaining / total, monitoring state, noise readings, and message delivery; running expresses intent only.
  • Keep readouts, barcode scores, ring progress, and charts consistent with target / min / max / unit. Credit-score composites default to 300–850, which you can override.
  • Give series, metrics, groups, and cells stable IDs, real labels, and full units; missing points are never filled in.
  • Localize with labels, formatValue, and a licensed avatar slot. Respect reduced motion; add no polling or permanent animation.

API Reference

Props

PropTypeDefaultDescription
variantMotionMetricVariantm-progress-pianoCatalog, composite, or original interaction ID.
interactionMotionMetricInteractionprogress-indicator-pianoInteraction branch, used only by animated-metric-card.
dataMotionMetricData—The caller's dataset.
seriesMotionMetricSeries[]—Overrides the current dataset's series.
metricsMotionMetricReadout[]—Overrides the current dataset's readouts.
statusstring—Caller status; never read as business success.
periodstringFirst periodCurrent period, bound with v-model:period.
periodsMotionMetricPeriod[]—Period options, each with its own data.
filterStyle'pills' | 'select'Source-appropriateNative pills or a native select.
activeIndexnumber0Controlled chart, matrix, or step index.
modelValuenumberdata.value / data.thresholdNumeric readout; the threshold in alert layouts.
range[number, number][data.min ?? 30, data.max ?? 120]Noise range bounds; emits input, never measures audio.
runningbooleanfalseTimer running state; starts no internal clock.
messagestringEmptyFeedback draft.
disabledbooleanfalseDisables native inputs and action events.
animatedbooleantrueEnables value and gauge motion, still gated by visibility and reduced motion.
size'xs' | 'sm' | 'md' | 'lg'mdSpacing and numeral size.
labelsPartial<MotionMetricLabels>English defaultsOverrides control and empty-state strings.
formatValue(value: number | string, unit?: string) => stringNumber with up to 2 decimals + unitFormats display only; chart data is untouched.

Events

EventPayloadDescription
update:periodstringFires when a period is chosen.
update:activeIndexnumberFires when a chart point, matrix cell, or step is chosen.
update:modelValuenumberFires when progress, noise value, or alert threshold changes.
update:range[number, number]Fires when the noise bounds change.
update:runningbooleanStart or pause intent; there is no internal clock.
update:messagestringFires when the feedback draft changes.
select{ id: string, index: number }Fires when a data point is chosen; chart points have an empty id.
filter{ groupId: string, period: string }Fires when a dashboard group switches period.
actionstringdetails, share, more, add, resume, or all.
sendstringSends the trimmed, non-empty message.

Slots

SlotScopeDescription
header{ data }Custom heading area.
avatar—A licensed avatar from the caller.
preview{ data }Content preview in the feedback layout.
footer{ data }Source, unit, or update time.

Types

TypeFieldsDescription
MotionMetricDatatitle, description, value, target, min, max, unit, previous, rank, status, remaining, total, threshold, columns, metrics, series, groups, cells, weekdays, steps, profiles, messagesNo business defaults; remaining / total are seconds, and gauge target defaults to 100.
MotionMetricSeriesid, label, points, unit?, tone?Independent series; points have label / value, plus optional description, tone, and sleep-stage level (0–100).
MotionMetricReadoutid, label, value, unit?, previous?, target?, description?, status?, tone?, grade?Numeric or text readout; grade serves credit reports.
MotionMetricGroupid, label, value?, target?, unit?, columns?, cells?, metrics?, series?, period?, periods?Named sub-layout; sales, finance, and credit groups can carry their own periods, controlled when period is set.
MotionMetricCellid, label, value, description?, selected?Activity intensity or calendar day; selection emits id and index.
MotionMetricStepid, label, value, status?Relative segment width and caller step state.
MotionMetricProfileid, name, initials?, status, detail?, value?, segments?, flight?flight holds label/from/to/departure/arrival/progress (0–100); no avatar URL is bundled.
MotionMetricMessageid, author, text, time?Caller messages; send neither appends nor claims delivery.
MotionMetricPeriodvalue, label, dataSelected data merges over base data; top-level series / metrics / status win.

Group IDs

VariantGroup IDsDescription
cache-stats-card / cacheable-bandwidth-costbandwidthgroup.value / unit is the cacheable amount; group.metrics is the cached and non-cacheable split.
network-telemetryAny IDEach group is a named activity matrix.
sales-dashboardanalytics, targetPaired bars and segmented sales target.
credit-score-cardsreport, utilization, historyGraded rows, balance/limit, and score history.
finance-dashboardsavings, credit, expenses, assetsPixel savings, barcode, stacked expenses, and filterable asset allocation.
marketing-cardschannels, campaignChannel allocation and chart/readout split.
health-cardsgoals, period, hydration, workout, steps, sleep, heart, targetDaily rings, cycle dots, charts, sleep stages, and weekly target.
system-metrics-cardAny IDEach group has quantiles and its own chart; top-level metrics are the error breakdown.
course-progress-cardAny IDTraining chart and attendee readouts.

MotionMetricLabels

Keys and defaults of labels, exported as MOTION_METRIC_DEFAULT_LABELS:

{
  period: 'Period', empty: 'No data for this period', details: 'View details', share: 'Share', more: 'More actions',
  scrubber: 'Select a data point', current: 'Current', target: 'Target', remaining: 'Remaining',
  low: 'Low', high: 'High', minimum: 'Minimum', maximum: 'Maximum', threshold: 'Threshold',
  start: 'Start', pause: 'Pause', message: 'Message', send: 'Send', all: 'See all', resume: 'Resume',
  analysis: 'Analysis', average: 'Average',
}

CSS Variables

VariablePurpose
--tx-mm-padRoot padding.
--tx-mm-gapSection spacing.
--tx-mm-numberNumeral size.
--tx-chart-categorical-1..6Series colors.
--tx-chart-grid-lineChart reference grid.
--tx-color-*, --tx-text-color-*, --tx-fill-color-*, --tx-bg-color, --tx-border-color-*Shared semantic theme.

Variants and Source Mapping

Catalog Entries

Catalog IDInteractionCapability
m-cache-bandwidthcacheable-bandwidth-costCached / non-cacheable allocation, total, and cost
m-net-matrixnetwork-telemetry-matrixFinality readouts and independent network matrices
m-progress-pianoprogress-indicator-piano28 piano keys and numeric goal input
m-server-stepserver-performance-step-barsStaircase columns with bright top caps
m-overview-scrubberoverview-bar-scrubber-cardStriped columns, active point, and scrubber tooltip
m-sales-dualsales-analytics-dual-barsSales / earnings paired bars and unit target
m-sales-arcsales-target-segmented-arcListed / delivered segmented half-circle
m-sales-radial-dashsales-overview-radial-dashboardRank banner, radial goal, and two readouts
m-credit-barcodecredit-score-barcode-meter42-stroke credit meter with period dropdown
m-mono-stockmono-stockMonochrome stock curve, period data, and hover values
m-users-pillusers-growth-pill-progressStar/profile header and selectable pill bars
m-views-waveviews-hourly-wave-chartHourly wave, actual average, and period filtering
m-mono-heatmapmono-heatmapCaller-owned 28-day grayscale activity matrix
m-timer-preptimer-preparation-segmentedRemaining time, selected stage, and segmented steps
m-noise-levelnoise-decibel-levelSignal bars, current input, and paired range controls

Source Capabilities

Paths are relative to upstream src/components/metrics/; MOTION_METRIC_SOURCE_MAP exports the full mapping.

SourceVariantCapability
AnimatedMetricCard.tsxanimated-metric-card29 interaction branches; no universal fallback card
Budget.tsxbudgetThree-row 64-column budget matrix and details event
CacheStatsCard.tsxcache-stats-cardQuery/cache readouts and bandwidth breakdown
CourseProgressCard.tsxcourse-progress-cardCourse ring, resume/all actions, training bars, and attendees
CreditScoreCards.tsxcredit-score-cardsScore half-circle, graded report, utilization, and history curve
FeedbackCard.tsxfeedback-cardCaller preview, editable message, send event, and message list
FinanceDashboard.tsxfinance-dashboardSavings pixels, credit barcode, stacked expenses, and asset filter
Growth.tsxgrowthThree pixel-height growth columns
GrowthCalendar.tsxgrowth-calendarSelectable growth pills and caller calendar
HealthCards.tsxhealth-cardsDaily rings, cycle dots, hydration, workout, steps, sleep stages, heart rate, and weekly target
MarketingCards.tsxmarketing-cardsChannel allocation and campaign chart/readout split
NetworkTelemetry.tsxnetwork-telemetrySummary statistics and per-network pixel matrices
NoiseCards.tsxnoise-cardsSeparate noise readings and paired range controls
OverviewChart.tsxoverview-chartMonthly striped columns and selected readout
ProgressIndicator.tsxprogress-indicator36-key progress, comparison, and numeric input
PromptsCard.tsxprompts-card30-segment prompt quota meter
RealTimeAlerts.tsxreal-time-alertsBudget bars and editable threshold line; emits input only
RunningStatsCard.tsxrunning-stats-cardDistance/duration and daily bars including zero days
SalesDashboard.tsxsales-dashboardFour summary stats, paired sales bars, and segmented target
SalesOverview.tsxsales-overviewRank banner, 12-segment goal, and two stats
SavingsCards.tsxsavings-cardsSavings progress, add event, target, and transaction columns
ServerPerformance.tsxserver-performanceCapped staircase performance columns
StatusCards.tsxstatus-cardsProfiles, activity/sleep timelines, and flight progress
StockChartCard.tsxstock-chart-cardSupplied stock series with first/last delta
SystemMetricsCard.tsxsystem-metrics-cardLatency/lag charts, quantiles, and error breakdown
TimerCard.tsxtimer-cardRemaining seconds, stage tooltip, steps, and running event
UserMetrics.tsxuser-metricsFour audience statistics and a views/average wave
UsersChartCard.tsxusers-chart-cardAudience area, secondary readouts, and details event
VisitorsChartCard.tsxvisitors-chart-cardTwo independent visitor curves and multi-series tooltip

AnimatedMetricCard Interactions

The catalog's 15 interactions plus the 14 below make up all 29 branches. Pass one directly as variant, or use variant="animated-metric-card" with interaction.

InteractionCapability
mono-revenueRevenue curve
mono-creditCredit ring and tier
mono-walletBalance and inflow/outflow
mono-savingsSavings target and progress
mono-activity-ringConcentric independent activity goals
mono-usersActive users and regional badges
mono-kfactorReferral multiplier ring
mono-latencyQuantiles and latency polyline
mono-bandwidthSpeed half-circle and latency/loss
mono-serverIndependent CPU/RAM rings and node/heap data
mono-progressBuild ring, steps, and caller status
mono-radarIncident half-circle and caller alert counts
mono-timer-arcRemaining-time ring and start/pause event
mono-timer-ringIndependent focus/break concentric rings

Overview

  • The component queries no network, audio, health, financial, or monitoring service, generates no data, and starts no timer; the caller updates series, metrics, status, remaining, and the rest.
  • Missing data shows an empty state, never fixed readings.
  • Charts expose keyboard-operable data-point scrubbers; the noise bounds natively limit each other, so they never cross.
  • Value and gauge motion stops offscreen, in hidden documents, in inactive KeepAlive instances, and under reduced motion.

Technologies

  • Reuses SVG/D3 charts, TxStatCard, TxSlider, TxInput, TxButton, and TxTextMorph.
  • Upstream: the Metrics components at Amicro commit 43c29ce, MIT, Copyright (c) 2026 SYED SUBHAN UDDIN.
  • Source: packages/tuffex/packages/components/src/motion-metric/.
查看源码
packages/tuffex/packages/components/src/motion-metric/index.ts