Chart card
A framed chart with its headline value, variation and comparison legend. Use it on a dashboard instead of a bare chart.
ChartCard wraps one chart in a card and surfaces the metric around it: a title with an optional icon and description, a large formatted headline value with its delta badge versus the comparison period, an optional primary / comparison legend, and the chart filling the body. The card owns the data; the nested chart only says how to draw it.
ChartCardA chart card reads its series from fetchUrl. This preview uses fixed sales data from the preview service, without a playground module or access to your application's data. If the live renderer is unavailable, the documentation shows a static screenshot instead.
Usage
import { ChartCard } from "@antelopejs/interface-dms/base/chart-card";
import { ChartArea } from "@antelopejs/interface-dms/base/chart";
static trend = ChartCard({
title: "$shop.sales.trend",
fetchUrl: "/api/sales/series",
periodScope: "sales",
valueFormat: "currency",
currencyCode: "EUR",
chart: ChartArea({ smooth: true, comparisonStyle: "dashed", xaxisType: "datetime" }),
});
The route answers the headline and the series:
@Get("series")
series() {
return {
value: 48200,
delta: 12.4,
previousValue: 42900,
series: [{ name: "$shop.sales.revenue", data: [{ x: "2026-10-01", y: 4200 }, { x: "2026-10-02", y: 4800 }] }],
comparisonSeries: [{ name: "$shop.sales.previous", data: [{ x: "2026-10-01", y: 3900 }, { x: "2026-10-02", y: 4100 }] }],
};
}
Each series name, each category x and each point label follow the $-prefix convention: a $ key is translated in the browser, in the language on screen, and reaches the legend, the axis, the slices, the tooltip and the POINT_CLICK payload translated. A date, a number or a string without the $ is drawn as sent.
Options
| Option | Type | Default | Description |
|---|---|---|---|
title* Content | string | – | Card heading. |
description Content | string | – | |
primaryLabel Content | string | – | |
comparisonLabel Content | string | – | |
icon Appearance | string | – | |
valueFormat Appearance | "number" | "currency" | "percent" | "compact" | – | |
currencyCode Appearance | string | – | |
showDelta Appearance | boolean | true | |
showLegend Appearance | boolean | true | |
showSeriesLegend Appearance | boolean | – | Name each series of the chart. |
invert Behavior | boolean | – | Treat a falling value as the good outcome. |
The card supplies its chart's title, description, showLegend, fetchUrl, fetchUrlMethod, periodScope and realtimeTopic; set presentation options on the chart instead (smooth, comparisonStyle, xaxisType, height, legendPosition). valuePrecision is available in code (Value precision).
Recipes
Name several series
A card plotting several series ("Average", "Max", "p95") names them with showSeriesLegend: true, placed by the chart's legendPosition:
import { ChartCard } from "@antelopejs/interface-dms/base/chart-card";
import { ChartLine } from "@antelopejs/interface-dms/base/chart";
ChartCard({
title: "$api.routes.response_time",
fetchUrl: "/api/routes/latency",
showSeriesLegend: true,
chart: ChartLine({ color: ["info", "neutral", "secondary"], legendPosition: "top" }),
});
A metric where lower is better
invert: true reads a fall as the good outcome, as on a KpiCard or a TopListCard: an error rate or a latency going up shows its delta in the error colour, going down in the success colour. The arrow still follows the raw direction.
import { ChartCard } from "@antelopejs/interface-dms/base/chart-card";
import { ChartLine } from "@antelopejs/interface-dms/base/chart";
ChartCard({ title: "$api.errors.rate", fetchUrl: "/api/errors/rate", valueFormat: "percent", invert: true, chart: ChartLine() });
Refresh on events
realtimeTopic makes the card read its route again on each event published there, keeping what it shows meanwhile. On a page declared with live, it reads at most once per maxRate.
Follow the selected comparison
With a periodScope, the card follows the comparison its PeriodSelector applies. The legend names the comparison series after it ("Previous period", "Previous year"; "Comparison" for a custom window) unless comparisonLabel names it, and the headline prints previousValue as "vs €42,900", formatted as the value. With "No comparison" selected, the card draws no change, no "vs" figure and no comparison series, whatever the route answers.
Pitfalls
- Never pass a raw ApexCharts
legendthroughrawOptionsto name series: useshowSeriesLegend. - Without
realtimeTopic, a card bound to a rolling period only moves when the period does.
