DashboardStats
Blocks for numbers: one metric with a change and a goal (KlyDashboardStat), several metrics in a block (KlyDashboardStats) and a value inside a range (KlyDashboardGauge). Values are formatted with a DashboardFormatPreset.
On this page
Examples
One metric
Given Compare, the stat computes the delta and the caption: +15.5% for 48,500 against 42,000. With CompareMode Difference a ratio such as 0.032 against 0.030 shows +0.2 pts, and InvertDelta turns a rise green or red the other way round, as for churn. Goal adds a progress bar and a percentage, Trend a sparkline of at least two points, Status a pill (a semantic color name such as success or warning) and TextValue replaces the number for a value that is not one. A Delta you pass takes precedence over Compare.
Revenue
Churn
Orders
API status
<KlyDashboardGrid>
<KlyDashboardStat Label="Revenue" Span="6" Value="48500" Compare="42000" Format="DashboardFormatPreset.Compact" />
<KlyDashboardStat Label="Churn" Span="6" Value="0.032" Compare="0.030" Format="DashboardFormatPreset.Ratio"
CompareMode="DashboardCompareMode.Difference" InvertDelta="true" Caption="vs 3.0% last month" />
<KlyDashboardStat Label="Orders" Span="6" Value="870" Goal="1200" Format="DashboardFormatPreset.Integer"
Trend="_orders" Status="@(new("On track", "success"))" />
<KlyDashboardStat Label="API status" Span="6" TextValue="Operational" Caption="Checked a minute ago"
Status="@(new("Degraded in APAC", "warning"))" />
</KlyDashboardGrid>
@code {
private static readonly IReadOnlyList<double> _orders = [610, 640, 590, 700, 760, 820, 870];
}Several metrics
Each DashboardStatsItem has its own Format, Delta, InvertDelta, Caption, Progress (a bar from 0 to 100) and Status. The metrics sit in a grid of up to four columns, plain by default, or each in a bordered tile with Variant Tiles. A null Value shows a dash.
This month
Plain: metrics side by side with no frame
This month
Tiles: each metric in a bordered tile
<KlyDashboardGrid>
<KlyDashboardStats Title="This month" Subtitle="Plain: metrics side by side with no frame" Items="_items" />
<KlyDashboardStats Title="This month" Subtitle="Tiles: each metric in a bordered tile" Items="_items" Variant="DashboardStatsVariant.Tiles" />
</KlyDashboardGrid>
@code {
private static readonly IReadOnlyList<DashboardStatsItem> _items =
[
new("revenue", "Revenue", 48_500, DashboardFormatPreset.Compact, Delta: 15.5, Caption: "vs last month"),
new("orders", "Orders", 870, DashboardFormatPreset.Integer, Progress: 72, Caption: "Goal 1,200"),
new("churn", "Churn", 3.2, DashboardFormatPreset.Percent, Delta: 0.4, InvertDelta: true),
new("sla", "SLA", 99.2, DashboardFormatPreset.Percent, Status: new DashboardStatus("At risk", "warning")),
];
}Gauge
The ring shows the value in the middle and the target as text under the gauge. The bar variant shows a meter with the value above it, the minimum and the maximum under it and a marker at the target. Min defaults to 0 and Max to 100.
CPU
Ring, the default
Storage
Bar, with a marker at the target
<KlyDashboardGrid>
<KlyDashboardGauge Title="CPU" Subtitle="Ring, the default" Span="6" Value="72" Target="80"
Format="DashboardFormatPreset.Percent" Caption="of capacity" />
<KlyDashboardGauge Title="Storage" Subtitle="Bar, with a marker at the target" Span="6" Variant="DashboardGaugeVariant.Bar"
Value="340" Min="0" Max="500" Target="400" Format="DashboardFormatPreset.Integer" Caption="GB used" />
</KlyDashboardGrid>API
KlyDashboardStat
A single metric with an optional delta, sparkline, goal bar and status pill.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Caption |
string |
A line of text under the value. Replaces the default vs ... previous period caption. | |
Card |
bool |
true |
Whether the block draws its own surface (border, background and shadow; only the background in a panels grid). Defaults to true . |
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Compare |
Double? |
The previous value. When Delta is not set, the delta is computed from it, and the default caption names it. | |
CompareMode |
Dashboard |
Dashboard |
Change (the default) computes the percent change from Compare and shows nothing when Compare is zero. Difference uses the raw difference, multiplied by 100 for the Ratio format. Values: Change, Difference. |
Delta |
Double? |
The change to display, in percent. It takes precedence over Compare . | |
DeltaFormat |
Dashboard |
How the delta is formatted. Defaults to Delta , or to Points or Signed when CompareMode is Difference . Values: Number, Integer, Decimal, Compact, Percent, Ratio, Delta, Points, Signed. |
|
Format |
Dashboard |
Dashboard |
How Value , Compare and Goal are formatted. Values: Number, Integer, Decimal, Compact, Percent, Ratio, Delta, Points, Signed. |
Freshness |
bool? |
Shows an Updated footer built from Source.UpdatedAt . When null , the value of the enclosing KlyDashboardGrid.Freshness applies, or false outside a grid. | |
Goal |
Double? |
A target that adds a progress bar and a percentage. It must be greater than 0. | |
InvertDelta |
bool |
false |
When set, a negative delta is shown as good news (for churn, cost or latency). |
Label |
string |
The name of the metric, shown as the card title. Required. | |
Menu |
bool? |
Shows the View as table, Download CSV and Expand buttons in the header once the content is displayed. Download CSV saves the block's table as a CSV file named after the title. When null , the value of the enclosing KlyDashboardGrid.Menu applies, or false outside a grid. | |
Source |
IDashboardSource |
The resource whose state drives the block: a skeleton while it loads, an error message with a retry button, then the content. The block does not read Data from it, so pass the data through the other parameters. Without a source the content renders immediately. | |
Span |
int |
4 |
Width of the block in columns of the grid, clamped between 1 and the Columns of the enclosing KlyDashboardGrid (12 outside a grid). Defaults to 4. |
Status |
DashboardStatus |
A status pill in the header. | |
TextValue |
string |
Text shown instead of the formatted Value , for values that are not numbers. | |
Trend |
IReadOnlyList |
Points of a sparkline. It needs at least two values. | |
Value |
Double? |
The value, formatted with Format . |
KlyDashboardStats
Several metrics side by side, each with an optional delta, progress bar and status pill.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Card |
bool |
true |
Whether the block draws its own surface (border, background and shadow; only the background in a panels grid). Defaults to true . |
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Freshness |
bool? |
Shows an Updated footer built from Source.UpdatedAt . When null , the value of the enclosing KlyDashboardGrid.Freshness applies, or false outside a grid. | |
Items |
IReadOnlyList |
The metrics, laid out in a grid of up to four columns. | |
Menu |
bool? |
Shows the View as table, Download CSV and Expand buttons in the header once the content is displayed. Download CSV saves the block's table as a CSV file named after the title. When null , the value of the enclosing KlyDashboardGrid.Menu applies, or false outside a grid. | |
Source |
IDashboardSource |
The resource whose state drives the block: a skeleton while it loads, an error message with a retry button, then the content. The block does not read Data from it, so pass the data through the other parameters. Without a source the content renders immediately. | |
Span |
int |
12 |
Width of the block in columns of the grid, clamped between 1 and the Columns of the enclosing KlyDashboardGrid (12 outside a grid). Defaults to 12. |
Subtitle |
string |
A secondary line under the title. | |
Title |
string |
The heading of the block. | |
Variant |
Dashboard |
Dashboard |
Plain (the default) or Tiles , which puts each metric in a bordered tile. Values: Plain, Tiles. |
KlyDashboardGauge
A gauge that shows a value between a minimum and a maximum, as a ring or a horizontal bar.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Caption |
string |
A line of text under the value inside the ring, or next to the value in the bar variant. | |
Card |
bool |
true |
Whether the block draws its own surface (border, background and shadow; only the background in a panels grid). Defaults to true . |
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Format |
Dashboard |
Dashboard |
How the value and the target are formatted. Values: Number, Integer, Decimal, Compact, Percent, Ratio, Delta, Points, Signed. |
Freshness |
bool? |
Shows an Updated footer built from Source.UpdatedAt . When null , the value of the enclosing KlyDashboardGrid.Freshness applies, or false outside a grid. | |
Max |
Double |
100 |
The value at which the gauge is full. Defaults to 100. |
Menu |
bool? |
Shows the View as table, Download CSV and Expand buttons in the header once the content is displayed. Download CSV saves the block's table as a CSV file named after the title. When null , the value of the enclosing KlyDashboardGrid.Menu applies, or false outside a grid. | |
Min |
Double |
0 |
The value at which the gauge is empty. Defaults to 0. |
Source |
IDashboardSource |
The resource whose state drives the block: a skeleton while it loads, an error message with a retry button, then the content. The block does not read Data from it, so pass the data through the other parameters. Without a source the content renders immediately. | |
Span |
int |
4 |
Width of the block in columns of the grid, clamped between 1 and the Columns of the enclosing KlyDashboardGrid (12 outside a grid). Defaults to 4. |
Subtitle |
string |
A secondary line under the title. | |
Target |
Double? |
A target shown as text under the gauge, and as a marker on the bar of the bar variant. | |
Title |
string |
The heading of the block. | |
Value |
Double? |
The current value. | |
Variant |
Dashboard |
Dashboard |
Ring (the default) draws a circular gauge with the value in the middle. Bar draws a horizontal meter with the value above it, the minimum and maximum under it and a marker at Target . The variant drawn is exposed as data-variant . Values: Ring, Bar. |