Metric grid ruled grid — Charts block
Procharts-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-gridUsage
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.
| Prop | Type | Description |
|---|---|---|
| title | string | Wordswhat the grid measures ("Payments overview") |
| intro | string | Wordsone line under the title ("Compared with the previous period") |
| periods* | Period[] | the periods the switch offers, as the host names them, 2 to 6 |
| period | string | Designthe selected period’s id; the first period by default |
| periodLink | string | Actionthe 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 |
| customize | string | Actionthe page where the user picks the metrics shown |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Period periods[] · 4 props
| Prop | Type | Description |
|---|---|---|
| id* | string | Designthe period’s key, sent back in its address ("30d") |
| label* | string | Wordsthe period as the switch writes it ("30 days") |
| range | string | Wordsthe dates this period covers, the legend’s first swatch ("Oct 1 – Oct 30") |
| previousRange | string | Wordsthe dates it is compared to, the legend’s second swatch ("Sep 1 – Sep 30") |
Metric metrics[] · 9 props
| Prop | Type | Description |
|---|---|---|
| id* | string | Designthe metric’s key ("gross-volume") |
| label* | string | Wordswhat the metric measures ("Gross volume") |
| value* | string | Wordsthe figure for the period, formatted by the host ("$48,210.40"): the block never computes it |
| change | string | Wordsits 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) |
| previous | number[] | Datathe values over the previous period, oldest first, drawn as a quiet line under this period’s area |
| axis | string[] | Wordslabels under the chart, spread evenly from the first point to the last, seven at most |
| unit | string | Designwritten after each value the chart reads out ("%", "ms", "USD") |
Options options · 1 props
| Prop | Type | Description |
|---|---|---|
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a 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).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| Link | your router’s link component |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your 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:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too 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
metricsfrom 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.