[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationTop list

Top list

A ranked leaderboard card. Its rows have a value, a delta, a bar and an optional sparkline.

TopListCard lists rows in rank order: an optional rank badge, an icon or avatar, a title and a description, a formatted value, an optional delta and an optional row sparkline. The top rows can be highlighted, rows can link elsewhere, and an empty list shows emptyLabel.

Top list TopListCard
Connecting to the DMS preview…
Connecting DMS 0.25.8 9 options set

Usage

src/pages/sales.ts ts
import { TopListCard } from "@antelopejs/interface-dms/base/top-list-card";

static products = TopListCard({
  title: "$shop.sales.top_products",
  fetchUrl: "/api/sales/top-products",
  periodScope: "sales",
  valueFormat: "currency",
  currencyCode: "EUR",
  showRank: true,
  highlightTopN: 3,
});

The route answers { items: TopListItem[] }. An item carries an id, a title and a value, plus optional description, valueLabel, delta (in percent), sparkline, icon, avatar (src, alt) and to.

Options

Options of the Top list block
OptionTypeDefaultDescription
title* Contentstring–Card heading.
description Contentstring–
emptyLabel Contentstring–
valueFormat Appearance"number" | "currency" | "percent" | "compact"–
currencyCode Appearancestring–
valueSuffix Appearancestring–Text after each value, such as " ms" (with its leading space).
showRank Appearanceboolean–
highlightTopN Appearancenumber–How many leading rows to highlight.
rankColor Appearancestring–
showDelta Appearanceboolean–
showBar Appearanceboolean–
showSparkline Appearanceboolean–
sparklineAccent Appearancestring–
badgeColor Appearancestring–
maxHeight Appearancestring–
invert Behaviorboolean–

valuePrecision is available in code (Value precision).

Recipes

A unit after each value

valueSuffix: " ms" with valuePrecision: 0 turns 1864 into "1,864 ms". The suffix is written as given, so the space goes in it; a $ key is translated. A row whose figure no format can write sends a valueLabel instead: a string, a $ key or a composed text. It replaces the value and its suffix while value still sizes the bar.

Rows that keep the reader's scope

A row's to may carry {{params.X}} / {{query.X}}, filled from the page URL when the row is drawn. A route answering to: "/modules/shop/products?id=42&store={{query.store}}" keeps the reader's store without knowing it.

Changes follow the comparison

With a periodScope and "No comparison" selected on its PeriodSelector, the rows show no change and the trend column goes, even if the route still answers a delta.

Pitfalls

  • skeletonCount defaults to 10 loading rows; set it to the usual number of rows to keep the card's height.
  • A row's title and description take $ keys or composed texts; never format numbers into them on the server.

Next steps

Activity feed

Events over time instead of a ranking.

Chart card

The trend next to the ranking.