@antelopejs/interface-dms 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +70 -68
- package/dist/auth/db/models/sessions.model.d.ts +1 -0
- package/dist/auth/db/models/userExternalIdentities.model.d.ts +1 -0
- package/dist/auth/db/models/users.model.d.ts +1 -0
- package/dist/base/block-types.d.ts +1 -0
- package/dist/base/block-types.js +1 -0
- package/dist/base/block-types.js.map +1 -1
- package/dist/base/live-toggle.d.ts +2 -2
- package/dist/base/period-selector.d.ts +2 -2
- package/dist/base/table-view/schema.d.ts +4 -4
- package/dist/db/internal/exportJobs.model.d.ts +1 -0
- package/dist/db/internal/inviteResolutions.model.d.ts +1 -0
- package/dist/db/internal/tenantLifecycle.model.d.ts +1 -0
- package/dist/db/models/roles.model.d.ts +1 -0
- package/dist/db/models/tenantMembers.model.d.ts +1 -0
- package/dist/db/models/tenants.model.d.ts +1 -0
- package/dist/db/models/user_invites.model.d.ts +1 -0
- package/docs/.navigation.yml +2 -0
- package/docs/1.core/.navigation.yml +2 -0
- package/docs/1.core/1.introduction.md +169 -0
- package/docs/1.core/10.layout-banners.md +133 -0
- package/docs/1.core/2.pages-and-modules.md +647 -0
- package/docs/1.core/3.components.md +287 -0
- package/docs/1.core/4.permissions.md +279 -0
- package/docs/1.core/5.tenancy.md +356 -0
- package/docs/1.core/6.invites.md +239 -0
- package/docs/1.core/7.hooks.md +354 -0
- package/docs/1.core/8.realtime.md +147 -0
- package/docs/1.core/9.quick-actions.md +115 -0
- package/docs/2.auth/.navigation.yml +2 -0
- package/docs/2.auth/1.introduction.md +75 -0
- package/docs/2.auth/2.authentication.md +222 -0
- package/docs/2.auth/3.tokens-and-sessions.md +352 -0
- package/docs/2.auth/4.users.md +256 -0
- package/docs/2.auth/5.external-identities.md +122 -0
- package/docs/3.base/.navigation.yml +2 -0
- package/docs/3.base/1.introduction.md +202 -0
- package/docs/3.base/10.display-blocks.md +136 -0
- package/docs/3.base/2.types.md +402 -0
- package/docs/3.base/3.forms.md +349 -0
- package/docs/3.base/4.tables.md +608 -0
- package/docs/3.base/5.charts-and-widgets.md +466 -0
- package/docs/3.base/6.layout.md +431 -0
- package/docs/3.base/8.data-types.md +361 -0
- package/docs/3.base/9.helpers.md +414 -0
- package/docs/4.notifications/.navigation.yml +2 -0
- package/docs/4.notifications/1.introduction.md +79 -0
- package/docs/4.notifications/2.categories-and-subjects.md +212 -0
- package/docs/4.notifications/3.sending.md +283 -0
- package/docs/5.html-render/.navigation.yml +2 -0
- package/docs/5.html-render/1.introduction.md +372 -0
- package/docs/5.html-render/2.built-in-emails.md +107 -0
- package/docs/index.md +100 -0
- package/docs/tsconfig.json +11 -0
- package/package.json +24 -18
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Charts and Widgets"
|
|
3
|
+
description: "The chart module and the three card modules cover dashboard surfaces: a chart of a series, a single figure with a delta, a ranked list, and the period selector the others read their date range from."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Charts and Widgets
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The chart module and the three card modules cover dashboard surfaces: a chart of a series, a single figure with a delta, a ranked list, and the period selector the others read their date range from. Each one is a builder that produces a component description; each one either carries its data inline (`staticDataset`, `staticItems`, `staticValue`) or names a `fetchUrl` the frontend calls.
|
|
11
|
+
|
|
12
|
+
All of them are exported from the package root; the charts also have their own subpath.
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import {
|
|
16
|
+
ChartArea,
|
|
17
|
+
ChartCard,
|
|
18
|
+
KpiCard,
|
|
19
|
+
PeriodSelector,
|
|
20
|
+
TopListCard,
|
|
21
|
+
} from "@antelopejs/interface-dms/base";
|
|
22
|
+
// charts only
|
|
23
|
+
import { ChartLine, ChartType } from "@antelopejs/interface-dms/base/chart";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## A Dashboard in One Page
|
|
27
|
+
|
|
28
|
+
The widgets compose through the layout builders from [Layout and Containers](/docs/interfaces/base/layout). One `PeriodSelector` declares a scope id; every widget that names the same `periodScope` follows its range.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import {
|
|
32
|
+
PageController,
|
|
33
|
+
pagesCategory,
|
|
34
|
+
RegisterPage,
|
|
35
|
+
} from "@antelopejs/interface-dms/page";
|
|
36
|
+
import {
|
|
37
|
+
ChartArea,
|
|
38
|
+
ChartCard,
|
|
39
|
+
KpiCard,
|
|
40
|
+
PeriodSelector,
|
|
41
|
+
TopListCard,
|
|
42
|
+
} from "@antelopejs/interface-dms/base";
|
|
43
|
+
import { Grid, GridRow } from "@antelopejs/interface-dms/base/grid";
|
|
44
|
+
import { DefaultLayout } from "@antelopejs/interface-dms/base/layouts";
|
|
45
|
+
|
|
46
|
+
const SCOPE_ID = "ai-overview";
|
|
47
|
+
|
|
48
|
+
@RegisterPage()
|
|
49
|
+
export class OverviewPage extends PageController(
|
|
50
|
+
"overview",
|
|
51
|
+
{ displayName: "Overview", icon: "i-ph-chart-line", category: pagesCategory },
|
|
52
|
+
DefaultLayout({ fullWidth: true }),
|
|
53
|
+
) {
|
|
54
|
+
static periodSelector = PeriodSelector({
|
|
55
|
+
id: SCOPE_ID,
|
|
56
|
+
align: "right",
|
|
57
|
+
defaultPreset: "last-7-days",
|
|
58
|
+
defaultComparison: "previous-period",
|
|
59
|
+
presets: ["today", "last-7-days", "last-30-days"],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
static kpis = Grid({ gap: "1rem" }).child(
|
|
63
|
+
"kpiRow",
|
|
64
|
+
GridRow().child(
|
|
65
|
+
"actions",
|
|
66
|
+
KpiCard({
|
|
67
|
+
title: "Actions",
|
|
68
|
+
icon: "i-ph-lightning",
|
|
69
|
+
fetchUrl: "/ai/metrics/kpi/actions",
|
|
70
|
+
periodScope: SCOPE_ID,
|
|
71
|
+
valueFormat: "compact",
|
|
72
|
+
compareLabel: "vs previous period",
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
static activityRow = Grid({ gap: "1rem" }).child(
|
|
78
|
+
"row",
|
|
79
|
+
GridRow()
|
|
80
|
+
.child(
|
|
81
|
+
"activityChart",
|
|
82
|
+
ChartCard({
|
|
83
|
+
title: "AI activity",
|
|
84
|
+
description: "Actions over the selected period",
|
|
85
|
+
icon: "i-ph-chart-line",
|
|
86
|
+
fetchUrl: "/ai/metrics/series",
|
|
87
|
+
periodScope: SCOPE_ID,
|
|
88
|
+
valueFormat: "compact",
|
|
89
|
+
chart: ChartArea({ xaxisType: "datetime" }),
|
|
90
|
+
}),
|
|
91
|
+
{ colSpan: 2 },
|
|
92
|
+
)
|
|
93
|
+
.child(
|
|
94
|
+
"topSkills",
|
|
95
|
+
TopListCard({
|
|
96
|
+
title: "Top skills",
|
|
97
|
+
fetchUrl: "/ai/metrics/top-skills?limit=5",
|
|
98
|
+
periodScope: SCOPE_ID,
|
|
99
|
+
}),
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Chart Builders
|
|
106
|
+
|
|
107
|
+
There is one builder per chart type. Each takes its own props with the `type` discriminant optional — the builder fills it in — and returns a `ComponentBuilder` for that props type.
|
|
108
|
+
|
|
109
|
+
| Builder | `ChartType` | Props interface |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| `ChartLine` | `LINE` | `LineChartProps` |
|
|
112
|
+
| `ChartArea` | `AREA` | `AreaChartProps` |
|
|
113
|
+
| `ChartRangeArea` | `RANGE_AREA` | `RangeAreaChartProps` |
|
|
114
|
+
| `ChartBar` | `BAR` | `BarChartProps` |
|
|
115
|
+
| `ChartColumn` | `COLUMN` | `ColumnChartProps` |
|
|
116
|
+
| `ChartScatter` | `SCATTER` | `ScatterChartProps` |
|
|
117
|
+
| `ChartMixed` | `MIXED` | `MixedChartProps` |
|
|
118
|
+
| `ChartRadar` | `RADAR` | `RadarChartProps` |
|
|
119
|
+
| `ChartCandlestick` | `CANDLESTICK` | `CandlestickChartProps` |
|
|
120
|
+
| `ChartDonut` | `DONUT` | `DonutChartProps` |
|
|
121
|
+
| `ChartPie` | `PIE` | `PieChartProps` |
|
|
122
|
+
| `ChartRadialBar` | `RADIAL_BAR` | `RadialBarChartProps` |
|
|
123
|
+
| `ChartHeatmap` | `HEATMAP` | `HeatmapChartProps` |
|
|
124
|
+
|
|
125
|
+
`ChartType` is the enum behind the discriminant: `LINE`, `AREA`, `RANGE_AREA`, `BAR`, `COLUMN`, `SCATTER`, `DONUT`, `PIE`, `MIXED`, `RADAR`, `RADIAL_BAR`, `HEATMAP`, `CANDLESTICK`. `AnyChartProps` is the union of all thirteen props interfaces.
|
|
126
|
+
|
|
127
|
+
Every builder gives the component a display name from `title`, falling back to the chart's own name (`"Line Chart"`, `"Donut Chart"`, …), and a matching icon.
|
|
128
|
+
|
|
129
|
+
### Common Options
|
|
130
|
+
|
|
131
|
+
Every chart props interface extends [`BaseComponentProps`](/docs/interfaces/base/types) and adds:
|
|
132
|
+
|
|
133
|
+
| Option | Type | Description |
|
|
134
|
+
| --- | --- | --- |
|
|
135
|
+
| `title` | `string` | Chart title, also the component display name. |
|
|
136
|
+
| `description` | `string` | Chart description. |
|
|
137
|
+
| `color` | `ChartColor` | One colour or a colour list. |
|
|
138
|
+
| `height` | `string` | CSS height. |
|
|
139
|
+
| `width` | `number` | Width. |
|
|
140
|
+
| `showTooltip` | `boolean` | Show the value tooltip. |
|
|
141
|
+
| `showLegend` | `boolean` | Show the series legend. |
|
|
142
|
+
| `legendPosition` | `ChartLegendPosition` | `"top"` or `"bottom"`; defaults to `top` for the axis charts, `bottom` for the circular ones. |
|
|
143
|
+
| `fetchUrl` | `string` | URL the chart loads its data from. |
|
|
144
|
+
| `fetchUrlMethod` | `HttpMethod` | Method for `fetchUrl`. |
|
|
145
|
+
| `periodScope` | `string` | Id of the `PeriodSelector` whose range this chart follows. |
|
|
146
|
+
| `realtimeTopic` | `string \| string[]` | Realtime topics to subscribe the page to. |
|
|
147
|
+
| `rawOptions` | `KeyValuePair[]` | Escape hatch: extra key/value options passed through to the chart renderer. A plain key replaces that whole section; a dotted key (`markers.size`) sets one option inside it. |
|
|
148
|
+
| `rawCss` | `KeyValuePair[]` | Escape hatch: extra key/value CSS declarations. |
|
|
149
|
+
|
|
150
|
+
`KeyValuePair` is `{ key: string; value: string }`.
|
|
151
|
+
|
|
152
|
+
When `realtimeTopic` is set, the builder registers each topic against the page it is declared on, using `RegisterPageTopic` from `@antelopejs/interface-dms/realtime`.
|
|
153
|
+
|
|
154
|
+
### Cartesian Charts
|
|
155
|
+
|
|
156
|
+
`LineChartProps`, `AreaChartProps`, `RangeAreaChartProps`, `BarChartProps`, `ColumnChartProps`, `ScatterChartProps`, `MixedChartProps`, `RadarChartProps` and `CandlestickChartProps` share a second layer of options on top of the common ones:
|
|
157
|
+
|
|
158
|
+
| Option | Type | Description |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| `staticDataset` | `ChartSeries[]` | Inline data, as an alternative to `fetchUrl`. |
|
|
161
|
+
| `showGrid` | `boolean` | Draw the background grid. |
|
|
162
|
+
| `yRange` | `{ min: number; max: number }` | Fixed Y bounds. |
|
|
163
|
+
| `autoYRange` | `ChartAutoYRange` | Opt-in annotation-aware native Y bounds, padded and rounded to a round step. Explicit `yRange` wins. |
|
|
164
|
+
| `comparisonStyle` | `ComparisonStyle` | How the comparison series is drawn: `"dashed"`, `"solid"` or `"dimmed"`. |
|
|
165
|
+
| `smooth` | `boolean` | Smooth the line between points. |
|
|
166
|
+
| `curve` | `ChartCurve` | Line interpolation, honoured by the line, area, rangeArea and mixed types. Takes precedence over `smooth` when both are set. |
|
|
167
|
+
| `annotations` | `ChartAnnotation[]` | Horizontal reference lines on the Y axis. |
|
|
168
|
+
| `syncGroup` | `string` | Charts sharing a group name share their crosshair and tooltip position. |
|
|
169
|
+
| `xaxisType` | `"category" \| "datetime" \| "numeric"` | Interpretation of the X values. |
|
|
170
|
+
|
|
171
|
+
`ChartAutoYRange` exposes `padding?: number`, defaulting to `0.08`. The renderer
|
|
172
|
+
extends native bounds to include finite annotation `y` and `y2` coordinates, then
|
|
173
|
+
subtracts `abs(min) * padding` from the lower bound and adds `abs(max) * padding`
|
|
174
|
+
to the upper bound. At zero, the magnitude is 1 instead. Zero padding is valid;
|
|
175
|
+
negative or nonfinite padding uses the default. Native series handling remains
|
|
176
|
+
with the chart engine, including range and candle points and stacked series.
|
|
177
|
+
This option does not add data to empty charts or enforce a zero baseline.
|
|
178
|
+
The existing raw `yaxis` escape hatch remains the final override.
|
|
179
|
+
|
|
180
|
+
And each adds its own:
|
|
181
|
+
|
|
182
|
+
| Props | Extra options |
|
|
183
|
+
| --- | --- |
|
|
184
|
+
| `LineChartProps` | `strokeWidth?: number` |
|
|
185
|
+
| `AreaChartProps` | `fillOpacity?: number`, `stacked?: boolean` |
|
|
186
|
+
| `RangeAreaChartProps` | `fillOpacity?: number` |
|
|
187
|
+
| `BarChartProps` | `stacked?: boolean`, `barWidth?: number`, `roundedCorners?: boolean`, `orientation?: AxeOrientation` |
|
|
188
|
+
| `ColumnChartProps` | `stacked?: boolean`, `columnWidth?: number`, `roundedCorners?: boolean` |
|
|
189
|
+
| `ScatterChartProps` | `pointSize?: number`, `showLabels?: boolean` |
|
|
190
|
+
| `MixedChartProps` | `seriesDefs?: MixedChartSeriesDef[]` |
|
|
191
|
+
| `RadarChartProps` | `fillOpacity?: number` |
|
|
192
|
+
| `CandlestickChartProps` | — |
|
|
193
|
+
|
|
194
|
+
`MixedChartSeriesDef` declares how one series of a mixed chart is drawn: `{ name: string; type: ChartType.LINE | ChartType.AREA | ChartType.COLUMN | ChartType.RANGE_AREA; color?: ChartColorValue }`.
|
|
195
|
+
|
|
196
|
+
`ChartCurve` is `"smooth" | "straight" | "stepline"`. Prefer it to `smooth`, which only chooses between the first two.
|
|
197
|
+
|
|
198
|
+
`ChartAnnotation` draws a horizontal reference on the Y axis — a spend cap, a max bound, a volume capacity:
|
|
199
|
+
|
|
200
|
+
| Field | Type | Description |
|
|
201
|
+
| --- | --- | --- |
|
|
202
|
+
| `y` | `number` | Value the line sits at. Required. |
|
|
203
|
+
| `y2` | `number` | Set it to shade the band between `y` and `y2` instead of drawing a line. |
|
|
204
|
+
| `label` | `string` | Text on the annotation. |
|
|
205
|
+
| `color` | `ChartColorValue` | Annotation colour. |
|
|
206
|
+
| `dashed` | `boolean` | Draw the line dashed. |
|
|
207
|
+
|
|
208
|
+
`syncGroup` is what turns a grid of separate metrics into one readable timeline: give every chart on the page the same group name and hovering one moves the crosshair on all of them.
|
|
209
|
+
|
|
210
|
+
### Circular Charts
|
|
211
|
+
|
|
212
|
+
`CircularChartProps` extends the common options with `staticDataset?: DonutRecord[]` — a flat list of `{ label: string; value: number }` rather than series.
|
|
213
|
+
|
|
214
|
+
| Props | Extra options |
|
|
215
|
+
| --- | --- |
|
|
216
|
+
| `DonutChartProps` | `centralLabel?: string`, `centralSubLabel?: string`, `arcWidth?: number` |
|
|
217
|
+
| `PieChartProps` | — |
|
|
218
|
+
| `RadialBarChartProps` | `hollowSize?: string`, `showTotal?: boolean` |
|
|
219
|
+
|
|
220
|
+
### Heatmap
|
|
221
|
+
|
|
222
|
+
`HeatmapChartProps` extends the common options directly — not the cartesian layer — with `staticDataset?: ChartSeries[]`, `shadeIntensity?: number` and `distributed?: boolean`.
|
|
223
|
+
|
|
224
|
+
## Series and Points
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
import type {
|
|
228
|
+
ChartCandlePoint,
|
|
229
|
+
ChartSeries,
|
|
230
|
+
ChartSeriesPoint,
|
|
231
|
+
} from "@antelopejs/interface-dms/base/chart";
|
|
232
|
+
|
|
233
|
+
const series: ChartSeries[] = [
|
|
234
|
+
{
|
|
235
|
+
name: "Actions",
|
|
236
|
+
data: [
|
|
237
|
+
{ x: "2026-07-01", y: 12 },
|
|
238
|
+
{ x: "2026-07-02", y: 18 },
|
|
239
|
+
{ x: "2026-07-03", y: null },
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
| Type | Shape |
|
|
246
|
+
| --- | --- |
|
|
247
|
+
| `ChartSeries` | `name: string`, `data: Array<ChartSeriesPoint \| ChartCandlePoint \| ChartRangePoint \| number>`, `type?: ChartType`, `color?: ChartColorValue`, `strokeWidth?: number`, `strokeDashArray?: number` |
|
|
248
|
+
| `ChartSeriesPoint` | `x: string \| number \| Date`, `y: number \| null`, `label?: string` |
|
|
249
|
+
| `ChartCandlePoint` | `x: string \| number \| Date`, `y: [number, number, number, number]` |
|
|
250
|
+
| `ChartRangePoint` | `x: string \| number \| Date`, `y: [number, number]` — the low and high bound a range area fills between |
|
|
251
|
+
| `DonutRecord` | `label: string`, `value: number` |
|
|
252
|
+
|
|
253
|
+
A `null` `y` marks a gap. `ChartSeries.type` overrides the chart's own type for that series, which is what a mixed chart uses.
|
|
254
|
+
|
|
255
|
+
Set `strokeWidth` and `strokeDashArray` on each series, including comparison series, to keep stroke styling attached to the data when series are reordered, added or removed. Both values are non-negative pixel lengths: `strokeWidth: 0` hides the stroke and `strokeDashArray: 0` draws a solid line. A positive dash length draws repeating dashes; it is not a custom SVG dash pattern.
|
|
256
|
+
|
|
257
|
+
Each property falls back independently to the existing chart configuration when omitted. Series values override the chart-level `strokeWidth` and comparison defaults. Without series styles, line widths remain 3 pixels (1.5 for comparison series), and comparison dashes remain 4 pixels for `comparisonStyle: "dashed"`. `rawOptions` still wins last: a `stroke` entry replaces the entire generated stroke section, without deep merging.
|
|
258
|
+
|
|
259
|
+
These properties also survive mixed-series definition projection. Set them on the data series, not on the positional `seriesDefs`. Rendering follows the chart type's stroke support; circular records do not expose series strokes. This API does not change fills, interpolation, markers, axes or legends.
|
|
260
|
+
|
|
261
|
+
## Colours and Formats
|
|
262
|
+
|
|
263
|
+
| Type | Values |
|
|
264
|
+
| --- | --- |
|
|
265
|
+
| `ColorName` | `"primary"`, `"secondary"`, `"success"`, `"info"`, `"warning"`, `"error"`, `"neutral"`, `"accent"` |
|
|
266
|
+
| `ChartColorValue` | `ColorName` or a `#…`, `rgb…` or `hsl…` string |
|
|
267
|
+
| `ChartColor` | `ChartColorValue \| ChartColorValue[]` |
|
|
268
|
+
| `ComparisonStyle` | `"dashed"`, `"solid"`, `"dimmed"` |
|
|
269
|
+
| `ValueFormat` | `"number"`, `"currency"`, `"percent"`, `"compact"` |
|
|
270
|
+
|
|
271
|
+
`ColorName` is the chart palette and is distinct from the `Color` enum in [Shared Types](/docs/interfaces/base/types): it adds `accent` and it is a string union rather than an enum. `ValueFormat` is used by the three card components rather than by the charts themselves.
|
|
272
|
+
|
|
273
|
+
## Chart Events
|
|
274
|
+
|
|
275
|
+
| Namespace member | Value |
|
|
276
|
+
| --- | --- |
|
|
277
|
+
| `ChartEvents.SEGMENT_CLICK` | `"DmsComponent.Chart.SegmentClick"` |
|
|
278
|
+
| `ChartEvents.POINT_CLICK` | `"DmsComponent.Chart.PointClick"` |
|
|
279
|
+
|
|
280
|
+
## ChartCard
|
|
281
|
+
|
|
282
|
+
`ChartCard` wraps a chart in a card that owns the title, the fetch URL and the delta display, and holds the chart as a child under the id `"chart"`.
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { ChartArea, ChartCard } from "@antelopejs/interface-dms/base";
|
|
286
|
+
|
|
287
|
+
const card = ChartCard({
|
|
288
|
+
title: "Revenue",
|
|
289
|
+
description: "Billed amount over the selected period",
|
|
290
|
+
icon: "i-ph-currency-eur",
|
|
291
|
+
fetchUrl: "/metrics/revenue",
|
|
292
|
+
periodScope: "finance",
|
|
293
|
+
valueFormat: "currency",
|
|
294
|
+
currencyCode: "EUR",
|
|
295
|
+
showDelta: true,
|
|
296
|
+
chart: ChartArea({ xaxisType: "datetime" }),
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
`ChartCardBuilderOptions` is `ChartCardProps` plus one required field, `chart: Component`. The chart is taken out of the options and attached as the card's child, so the serialized card options are exactly `ChartCardProps`.
|
|
301
|
+
|
|
302
|
+
`ChartCardProps` extends `BaseComponentProps`:
|
|
303
|
+
|
|
304
|
+
| Option | Type | Description |
|
|
305
|
+
| --- | --- | --- |
|
|
306
|
+
| `title` | `string` | Card title. Required; also the component display name. |
|
|
307
|
+
| `description` | `string` | Card description. |
|
|
308
|
+
| `icon` | `string` | Card icon. Defaults to `"i-ph-chart-line"` for the component metadata. |
|
|
309
|
+
| `fetchUrl` | `string` | URL the card loads its data from. |
|
|
310
|
+
| `fetchUrlMethod` | `HttpMethod` | Method for `fetchUrl`. |
|
|
311
|
+
| `periodScope` | `string` | Id of the `PeriodSelector` to follow. |
|
|
312
|
+
| `valueFormat` | `ValueFormat` | How the headline value is formatted. |
|
|
313
|
+
| `currencyCode` | `string` | Currency for `valueFormat: "currency"`. |
|
|
314
|
+
| `valuePrecision` | `ValuePrecision` | Fixed fraction digits or `"native"` Intl defaults; omitted keeps legacy formatting. Also applies to the previous value and nested chart's value axis and tooltip. |
|
|
315
|
+
| `showDelta` | `boolean` | Show the change against the comparison period. |
|
|
316
|
+
| `showLegend` | `boolean` | Show the primary / comparison legend. Defaults to `true`. |
|
|
317
|
+
| `showSeriesLegend` | `boolean` | Show the nested chart's legend, naming each series. Defaults to `false`. |
|
|
318
|
+
| `primaryLabel` | `string` | Label of the primary series. |
|
|
319
|
+
| `comparisonLabel` | `string` | Label of the comparison series. |
|
|
320
|
+
|
|
321
|
+
## KpiCard
|
|
322
|
+
|
|
323
|
+
`KpiCard` shows a single figure with an optional delta and sparkline.
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
import { KpiCard } from "@antelopejs/interface-dms/base";
|
|
327
|
+
|
|
328
|
+
const denied = KpiCard({
|
|
329
|
+
title: "Denied",
|
|
330
|
+
icon: "i-ph-prohibit",
|
|
331
|
+
fetchUrl: "/ai/metrics/kpi/denied",
|
|
332
|
+
valueFormat: "compact",
|
|
333
|
+
invert: true,
|
|
334
|
+
compareLabel: "vs previous period",
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
`KpiCardProps` extends `BaseComponentProps`:
|
|
339
|
+
|
|
340
|
+
| Option | Type | Description |
|
|
341
|
+
| --- | --- | --- |
|
|
342
|
+
| `title` | `string` | Card title. Required; also the component display name. |
|
|
343
|
+
| `variant` | `"default" \| "stat"` | `"stat"` is the compact look: mono uppercase label, bare icon. |
|
|
344
|
+
| `description` | `string` | Card description. |
|
|
345
|
+
| `icon` | `string` | Card icon. Defaults to `"i-ph-trend-up"` for the component metadata. |
|
|
346
|
+
| `fetchUrl` | `string` | URL the card loads its value from. |
|
|
347
|
+
| `fetchUrlMethod` | `HttpMethod` | Method for `fetchUrl`. |
|
|
348
|
+
| `periodScope` | `string` | Id of the `PeriodSelector` to follow. |
|
|
349
|
+
| `valueFormat` | `ValueFormat` | How the value is formatted. |
|
|
350
|
+
| `currencyCode` | `string` | Currency for `valueFormat: "currency"`. |
|
|
351
|
+
| `valuePrecision` | `ValuePrecision` | Fixed fraction digits or `"native"` Intl defaults; omitted keeps legacy formatting. |
|
|
352
|
+
| `showDelta` | `boolean` | Show the change against the comparison period. |
|
|
353
|
+
| `showSparkline` | `boolean` | Show the sparkline. |
|
|
354
|
+
| `sparklineAccent` | `ChartColorValue \| "auto"` | Sparkline colour. |
|
|
355
|
+
| `invert` | `boolean` | Treat an increase as bad — for metrics where lower is better. |
|
|
356
|
+
| `compareLabel` | `string` | Label next to the delta. |
|
|
357
|
+
| `staticValue` | `number` | Inline value, as an alternative to `fetchUrl`. |
|
|
358
|
+
| `staticDelta` | `number` | Inline delta, in percent (`12.5` reads +12.5 %). |
|
|
359
|
+
| `staticSparkline` | `number[]` | Inline sparkline points. |
|
|
360
|
+
|
|
361
|
+
## TopListCard
|
|
362
|
+
|
|
363
|
+
`TopListCard` shows a ranked list of items, each with a value and optionally a delta, a sparkline and an avatar.
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { TopListCard } from "@antelopejs/interface-dms/base";
|
|
367
|
+
|
|
368
|
+
const topSkills = TopListCard({
|
|
369
|
+
title: "Top skills",
|
|
370
|
+
description: "Most-used tools over the selected period",
|
|
371
|
+
fetchUrl: "/ai/metrics/top-skills?limit=5",
|
|
372
|
+
periodScope: "ai-overview",
|
|
373
|
+
showRank: true,
|
|
374
|
+
highlightTopN: 3,
|
|
375
|
+
});
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
`TopListCardProps` extends `BaseComponentProps`:
|
|
379
|
+
|
|
380
|
+
| Option | Type | Description |
|
|
381
|
+
| --- | --- | --- |
|
|
382
|
+
| `title` | `string` | Card title. Required; also the component display name. |
|
|
383
|
+
| `description` | `string` | Card description. |
|
|
384
|
+
| `fetchUrl` | `string` | URL the card loads its items from. |
|
|
385
|
+
| `fetchUrlMethod` | `HttpMethod` | Method for `fetchUrl`. |
|
|
386
|
+
| `periodScope` | `string` | Id of the `PeriodSelector` to follow. |
|
|
387
|
+
| `valueFormat` | `ValueFormat` | How each item's value is formatted. |
|
|
388
|
+
| `currencyCode` | `string` | Currency for `valueFormat: "currency"`. |
|
|
389
|
+
| `valuePrecision` | `ValuePrecision` | Fixed fraction digits or `"native"` Intl defaults; omitted keeps legacy formatting. |
|
|
390
|
+
| `valueSuffix` | `string` | Unit written right after each formatted value, space included (`" ms"`); a `$`-prefixed key is translated. Not added to a `valueLabel`. |
|
|
391
|
+
| `showRank` | `boolean` | Show the rank number. |
|
|
392
|
+
| `highlightTopN` | `number` | How many leading items are highlighted. |
|
|
393
|
+
| `rankColor` | `ChartColorValue` | Colour of the rank marker. |
|
|
394
|
+
| `showDelta` | `boolean` | Show each item's delta. |
|
|
395
|
+
| `showSparkline` | `boolean` | Show each item's sparkline. |
|
|
396
|
+
| `sparklineAccent` | `ChartColorValue \| "auto"` | Sparkline colour. |
|
|
397
|
+
| `invert` | `boolean` | Treat an increase as bad. |
|
|
398
|
+
| `badgeColor` | `ChartColorValue` | Colour of the value badge. |
|
|
399
|
+
| `maxHeight` | `string` | CSS max-height before the list scrolls. |
|
|
400
|
+
| `staticItems` | `TopListItem[]` | Inline items, as an alternative to `fetchUrl`. |
|
|
401
|
+
| `emptyLabel` | `string` | Text shown when there are no items. |
|
|
402
|
+
| `skeletonCount` | `number` | Placeholder rows while `fetchUrl` loads: the "top N" it answers. Optional. Defaults to 10. |
|
|
403
|
+
| `actions` | `BlockLinkAction[]` | Link buttons in the card head, after the period badge; quiet ghost buttons unless one sets its own `variant` or `color`. |
|
|
404
|
+
|
|
405
|
+
`TopListItem` is the item shape, the element type of `staticItems`:
|
|
406
|
+
|
|
407
|
+
| Field | Type | Description |
|
|
408
|
+
| --- | --- | --- |
|
|
409
|
+
| `id` | `string \| number` | Item identifier. Required. |
|
|
410
|
+
| `title` | `BlockText` | Item label: a string or a `ComposedText`. Required. |
|
|
411
|
+
| `value` | `number` | Item value. Required. |
|
|
412
|
+
| `valueLabel` | `BlockText` | The value as written, in place of the formatted `value` (which still sizes the bar). |
|
|
413
|
+
| `description` | `BlockText` | Secondary line. |
|
|
414
|
+
| `delta` | `number \| null` | Change against the comparison period, in percent (`12.5` reads +12.5 %). |
|
|
415
|
+
| `sparkline` | `number[]` | Sparkline points. |
|
|
416
|
+
| `icon` | `string` | Leading icon. |
|
|
417
|
+
| `avatar` | `TopListItemAvatar` | Leading avatar, `{ src: string; alt?: string }`. |
|
|
418
|
+
| `to` | `string` | Link target for the item. `{{params.X}}` / `{{query.X}}` name the page URL; a query pair whose token has no value is left out. |
|
|
419
|
+
|
|
420
|
+
## PeriodSelector
|
|
421
|
+
|
|
422
|
+
`PeriodSelector` owns a date range and a comparison mode, and publishes them under its `id`. Every widget carrying the same value in `periodScope` uses that range.
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
import { PeriodSelector } from "@antelopejs/interface-dms/base";
|
|
426
|
+
|
|
427
|
+
const selector = PeriodSelector({
|
|
428
|
+
id: "finance",
|
|
429
|
+
align: "right",
|
|
430
|
+
defaultPreset: "this-month",
|
|
431
|
+
defaultComparison: "previous-year",
|
|
432
|
+
presets: ["this-month", "last-month", "ytd", "custom"],
|
|
433
|
+
presetLabels: { ytd: "Year to date" },
|
|
434
|
+
showRangeLabel: true,
|
|
435
|
+
});
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
`PeriodSelectorProps` extends `BaseComponentProps`:
|
|
439
|
+
|
|
440
|
+
| Option | Type | Description |
|
|
441
|
+
| --- | --- | --- |
|
|
442
|
+
| `id` | `string` | Scope identifier other widgets name in `periodScope`, and the prefix of the selector's URL keys. Defaults to `"page"` (`DEFAULT_PERIOD_SCOPE`). |
|
|
443
|
+
| `defaultPreset` | `PeriodPreset` | Preset selected when neither the URL nor the user's last choice names one. |
|
|
444
|
+
| `defaultComparison` | `PeriodComparison` | Comparison selected when neither the URL nor the user's last choice names one. |
|
|
445
|
+
| `presets` | `PeriodPreset[]` | Presets offered. |
|
|
446
|
+
| `comparisons` | `PeriodComparison[]` | Comparisons offered. |
|
|
447
|
+
| `presetLabels` | `Partial<Record<PeriodPreset, string>>` | Overrides for preset labels. |
|
|
448
|
+
| `comparisonLabels` | `Partial<Record<PeriodComparison, string>>` | Overrides for comparison labels. |
|
|
449
|
+
| `align` | `PeriodAlign` | `"left"`, `"center"` or `"right"`. |
|
|
450
|
+
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | Control size. |
|
|
451
|
+
| `showRangeLabel` | `boolean` | Show the resolved date range as text. |
|
|
452
|
+
| `rangeLabel` | `PeriodRangeLabel` | `"absolute"` (default): both bounds. `"relative"`: the start of a window reaching now, "since yesterday 11:52". |
|
|
453
|
+
| `comparisonControl` | `PeriodComparisonControl` | `"menu"`, `"toggle"` (one inline button switching a comparison on and off) or `"hidden"` (nothing drawn, the comparison kept on). Defaults to `"toggle"` when `comparisons` offers a single comparison besides `"none"`, `"menu"` otherwise. |
|
|
454
|
+
| `rememberKey` | `string` | Selectors carrying the same key share the remembered last choice, on any page. |
|
|
455
|
+
| `variant` | `PeriodSelectorVariant` | `"default"` or `"segmented"`. |
|
|
456
|
+
| `maxDays` | `number` | The longest custom range, in days (both ends included), the user can pick in the calendar or the date fields. Presets and a range given by the URL are not limited. |
|
|
457
|
+
|
|
458
|
+
`PeriodPreset` is `"last-hour"`, `"last-24h"`, `"today"`, `"yesterday"`, `"last-7-days"`, `"last-30-days"`, `"last-90-days"`, `"this-month"`, `"last-month"`, `"this-quarter"`, `"last-quarter"`, `"ytd"`, `"last-year"`, `"all"` or `"custom"`. `"all"` is every period: it has no bounds, so the bound widgets are sent no `from` / `to`. `PeriodComparison` is `"none"`, `"previous-period"`, `"previous-year"` or `"custom"`. `PeriodAlign` is `"left" | "center" | "right"`.
|
|
459
|
+
|
|
460
|
+
The selector keeps its period in the page URL, under keys prefixed with its `id`: `?<id>.period=<preset>&<id>.compare=<comparison>` for a preset, `?<id>.from=<date>&<id>.to=<date>` for a custom range (an ISO date, or an ISO date-time), plus `<id>.compareFrom` / `<id>.compareTo` for a custom comparison; `?<id>.period=all` for every period. A URL naming `from` / `to` opens on that range even when `"custom"` is not offered, with no preset selected, and is not remembered. It starts from the URL, then from the user's last choice on that selector of that page (or on any selector sharing its `rememberKey`), then from `defaultPreset` / `defaultComparison`; the range and the comparison are read apart, and an unknown value, one the selector does not offer, or an invalid range falls back silently to the next source. A change replaces the history entry instead of adding one. There is no option to turn this off.
|
|
461
|
+
|
|
462
|
+
`PeriodSelectorVariant` is `"default" | "segmented"`. `segmented` renders the presets as inline pills for one-click range switching; the custom range stays in its popover calendar either way.
|
|
463
|
+
|
|
464
|
+
## Next Steps
|
|
465
|
+
|
|
466
|
+
- [Layout and Containers](/docs/interfaces/base/layout) - Grids, stacks, tabs, layouts and the custom-component escape hatch.
|