Metric grid ruled grid — Charts block

Pro

charts-metric-grid-ruled-grid · for app, analytics pages

Metric grid ruled grid

An analytics page of the host’s own measures over a chosen period: one ruled grid of chart tiles sharing their borders, the first metric leading at two thirds, each with its value, this period against the previous and an area chart

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/charts-metric-grid-ruled-grid

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import ChartsMetricGridRuledGrid from '@/components/trame/blocks/charts/charts-metric-grid-ruled-grid.vue'

const props = {
title: "Payments overview",
intro: "Every figure compared with the period before it.",
periods: [
{
id: "7d",
label: "7 days",
range: "Oct 24 – Oct 30",
previousRange: "Oct 17 – Oct 23"
},
{
id: "30d",
label: "30 days",
range: "Oct 1 – Oct 30",
previousRange: "Sep 1 – Sep 30"
}
],
period: "30d",
periodLink: "analytics.period",
metrics: [
{
id: "gross-volume",
label: "Gross volume",
value: "$48,210.40",
change: "+12.4%",
changeTone: "success",
series: [
1567,
1636
],
previous: [
1388,
1235
],
axis: [
"Oct 1",
"Oct 8"
],
unit: "USD"
},
{
id: "net-volume",
label: "Net volume",
value: "$44,902.15",
change: "+9.8%",
changeTone: "success",
series: [
1518,
1426
],
previous: [
1086,
1014
],
axis: [
"Oct 1",
"Oct 8"
],
unit: "USD"
}
],
customize: "analytics.customize"
}
</script>

<template>
<ChartsMetricGridRuledGrid v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
titlestringWordswhat the grid measures ("Payments overview")
introstringWordsone line under the title ("Compared with the previous period")
periods*Period[]the periods the switch offers, as the host names them, 2 to 6
periodstringDesignthe selected period’s id; the first period by default
periodLinkstringActionthe page a period leads to: href(periodLink, { id }) is each period’s address, followed by the host’s link
metrics*Metric[]the metrics, 1 to 12, in order: the first one leads
customizestringActionthe page where the user picks the metrics shown
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Period periods[] · 4 props
PropTypeDescription
id*stringDesignthe period’s key, sent back in its address ("30d")
label*stringWordsthe period as the switch writes it ("30 days")
rangestringWordsthe dates this period covers, the legend’s first swatch ("Oct 1 – Oct 30")
previousRangestringWordsthe dates it is compared to, the legend’s second swatch ("Sep 1 – Sep 30")
Metric metrics[] · 9 props
PropTypeDescription
id*stringDesignthe metric’s key ("gross-volume")
label*stringWordswhat the metric measures ("Gross volume")
value*stringWordsthe figure for the period, formatted by the host ("$48,210.40"): the block never computes it
changestringWordsits change against the previous period, as the host states it ("+12.4%")
changeTone'neutral' | 'success' | 'warning' | 'danger'how the host reads that change: a rise in refunds is not good news; neutral by default
series*number[]Datathe values over the selected period, oldest first, in the unit they read in (dollars, not cents)
previousnumber[]Datathe values over the previous period, oldest first, drawn as a quiet line under this period’s area
axisstring[]Wordslabels under the chart, spread evenly from the first point to the last, seven at most
unitstringDesignwritten after each value the chart reads out ("%", "ms", "USD")
Options options · 1 props
PropTypeDescription
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
Linkyour router’s link component
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: link, link
  • Reads metrics from your app

A charts section, for app, analytics pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.

More charts blocks

  • Heatmap matrix: a labelled grid with each value written in its shaded cell: cohorts and retention, hours by weekday, when the exact numbers are read.
  • Heatmap ranked rows: the rows sorted by their total, each one a thin strip of its cells, when which row leads matters more than the columns.
  • Key metrics featured: The merchant’s own primary metric takes the lead beside a quiet list of supporting measures.
  • Key metrics tiles: Centered figures on generous tiles for the merchant’s own headline measures, with context beneath.
  • Spend trend stacked bars: a plan with variable spend: three figures and a stacked bar chart of what each period cost.
  • Stat cards linked: figures about goals or finance, each with a status line that leads to the detail.
  • Stat cards plain: two to six headline figures at a glance, each with its change when the server gives one.
  • Stat cards strip: one calm bordered band of figures, to sit inside another card above a chart or a table.

All 20 charts blocks