Skip to Content
DashboardsReferenceWidgetsStat (single value)

Stat (single value)

For: implementers. Setup: setting names match the ModularIoT web app.

Widgets that show one number, with a color by value or progress toward a goal. All of them read the first row of their query.

WidgetcomponentIdShows
Stat Cardstat_iconA number with an icon and a title
Status Cardstat_statusA status value (text or number) with a colored border
Progress Statstat_progressProgress toward a goal, with a bar and marks
Progresspercentage_valuevalue / max (percentage) with a bar
Circular Statstat_circularA ring with the value over a maximum

Other single-value widgets: Detailed Stat (stat_detailed), Sparkline Stat (stat_sparkline), Expandable Stat (stat_expandable), Sensitive Stat (stat_sensitive). See Catalog.

Data they read

One row, one column per number:

SELECT COUNTIF(estado != 'cerrada') AS abiertas, COUNTIF(estado = 'cerrada') AS cerradas, COUNT(*) AS total, 40 AS meta, ROUND(AVG(horas), 0) AS horas_promedio, 'Operativo' AS estado FROM `my-project.operations.solicitudes`

Each text field of the widget names a column with a template: {{cerradas}} or {{row.cerradas}}.

Variants

VariantWidgetSettingsQuery shapeScreenshot
Plain numberStat CardValue {{abiertas}}abiertasPlain number
Green, yellow, redStat CardValue Color Rules: > 48 red, > 24 yellow, <= 24 green; target Text and Iconhoras_promedioGreen, yellow, red
Text statusStatus CardValue {{estado}}; rule = Operativo → greenestado (text)Text status
Goal with thresholdsProgress StatValue {{cerradas}}, Target {{meta}}; Thresholds on {{row.cerradas}}cerradas, metaGoal with thresholds
Part of a totalProgressValue {{cerradas}}, Max {{total}}cerradas, totalPart of a total
RingCircular StatValue {{cerradas}}, Max {{total}}, Ring Colorcerradas, totalRing

Plain number

Stat Card Solicitudes abiertas 19

Green, yellow, red

18 h in green

36 h in yellow

52 h in red

Text status

Status Card Estado del servicio: Operativo in green

Goal with thresholds

Progress Stat Cerradas este mes 30 of 40 in yellow

Part of a total

Progress Cerradas sobre el total 30 / 49 (61%)

Ring

Circular Stat 30 of 49

Main settings

WidgetSettingKeyEffect
Stat Card, Progress Stat, Circular StatTitle, Value, Unittitle, value, unitAccept templates
Status CardTitle, Value, Subtitletitle, value, subtitleAccept templates. The value shows as text
ProgressTitle, Value, Maxtitle, value, maxAccept templates
Stat CardSubtitlesubtitleText under the value; accepts Markdown
Stat CardCard Layout: Horizontal / VerticalcardVariantIcon on the left or on top
Stat CardIcon, Background, Value Color, Secondary TextshowIcon, icon, iconColor, showBgColor, bgColor, showValueColor, valueColor, …Fixed colors
Stat CardGo toshowGoTo, goToUrlThe whole card is a link. Accepts templates
Stat Card, Status CardValue Color RulesvalueColorRules.rules[]: operator, value, color, targetsColor by value. A rule beats fixed colors
Status CardIconiconcheck, warning, clock, truck, …
Progress StatTargettargetGoal. The bar shows value / target
Progress StatThresholdsthresholds: field, applyTo, rules[]Bar color (Background) and value color (Text)
Progress StatBar Color RulesbarColorRulesBar color by value. Wins over thresholds
ProgressMax, Bar Color, Bar Color Rulesmax, barColor, barColorRulesRules compare the percentage or the value (buttons % / Count)
Circular StatMax, Ring Color, Ring Color RulesmaxValue, ringColor, ringColorRulesRing from 0 to 100%

Color rules and thresholds

OperatorCompares
=, !=When both sides contain a number, only the numbers are compared (other characters are removed). Otherwise, case-insensitive text
contains, !containsText, case-insensitive
>, <, >=, <=As numbers. Strips non-digit characters from the value
TypeEvaluation order
Value Color Rules> and >= from highest to lowest value, then < and <= from lowest to highest. =, != and contains keep their list position. Each target (Text, Background, Icon) takes the first matching rule
Thresholds (Progress Stat)List order. The first match wins

In a Stat Card, rules compare the value’s number. A text value (“OK”) becomes 0. For text states, use a Status Card.

Pitfall: in Thresholds, Evaluate field needs a template ({{row.cerradas}}). When it is empty, no rule applies.

Full example

{ "componentId": "stat_icon", "config": { "title": "Horas promedio de atención", "value": "{{horas_promedio}}", "unit": " h", "subtitle": "", "cardVariant": "horizontal", "showIcon": true, "icon": "clock", "iconColor": "3b82f6", "dataMode": "planner", "plannerVariableName": "kpis", "valueColorRules": { "rules": [ { "operator": "greater_than", "value": "48", "compareMode": "static", "color": "ef4444", "targets": ["text", "icon"] }, { "operator": "greater_than", "value": "24", "compareMode": "static", "color": "eab308", "targets": ["text", "icon"] }, { "operator": "less_than_or_equal", "value": "24", "compareMode": "static", "color": "22c55e", "targets": ["text", "icon"] } ] } } }

Limits

LimitAlternative
Read only the first rowOne column per number in the query
Stat Card turns a non-numeric value into 0Use a Status Card for text
The value has no thousands separatorIn a Status Card, use {{formatNumber total}}. Stat Card, Progress Stat, Progress and Circular Stat read the value as a number: with formatted text (12.500) they show another number or 0
Status Card and Circular Stat drop the static JSON when you save their settingsUse a saved query
On narrow widgets, a Stat Card title is cut offUse a short title or a wider widget
Last updated on