Skip to Content

Stacked Stat

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

Shows the parts of a total as a 100% bar or a donut, with a legend that gives each part’s value. Use it for “a KPI per state + a 100% bar”.

Stacked Stat with the bar Pendiente 12, En curso 7, Cerrada 30

Data it reads

It reads the first row of its query. Each category reads one column of that row through a template:

SELECT COUNT(*) AS total, COUNTIF(estado = 'pendiente') AS pendiente, COUNTIF(estado = 'en_curso') AS en_curso, COUNTIF(estado = 'cerrada') AS cerrada FROM `my-project.operations.solicitudes`
CategoryValue
Pending{{pendiente}}
In progress{{en_curso}}
Closed{{cerrada}}

If your query returns one row per state, turn it into columns: Pivot.

Variants

VariantSettingsQuery shapeScreenshot
BarChart Type: Bar, Unit emptyOne row, one column per categoryBar
DonutChart Type: Donut, Unit emptyThe sameDonut
No headerShow Header offThe sameNo header
PercentagesUnit: %, values {{pendiente_pct}}One row with percentages computed in the queryPercentages
Templated titleTitle: Requests by state ({{total}})One row with a total columnTemplated title

Bar

Bar with Pendiente 12, En curso 7, Cerrada 30

Donut

Donut with the same three parts

No header

Bar without a title

Percentages

Bar with Pendiente 24.5%, En curso 14.3%, Cerrada 61.2%

The query computes the percentages. See Percentages.

Templated title

Title Solicitudes por estado (49)

Settings

TabSettingDocument keyEffect
VisualizationShow HeadershowHeaderShows or hides the title. On by default
VisualizationChart Type: Bar / DonutchartType (bar, donut)Chart shape
VisualizationTitletitleAccepts templates
VisualizationUnitunitText after each value, with no space. Default %
VisualizationCategoriesitems[]: label, value, colorOne part per category. color in hex without #
VisualizationThresholdsthresholdsSaved, but the widget does not use it
Data ProviderData Source, VariabledataMode, plannerVariableNameplanner reads a saved query
Panel footerAuto-RefreshrefreshIntervalSeconds between reloads. Use dashboard setting removes the key

How the bar is computed

CaseResult
Positive valuesEach part is its value over the sum of the positive values
Value 0 or negativeNo part is drawn. The legend shows the value
Value that is not a numberTreated as 0
Every value 0The bar is grey
Color that is not a 6-digit hexGrey (9ca3af)

Hovering a part shows the label, the value with the unit and the percentage with one decimal: Pendiente: 12 (24.5%).

Full example

{ "componentId": "stat_stacked", "config": { "title": "Solicitudes por estado ({{total}})", "unit": "", "showHeader": true, "chartType": "bar", "dataMode": "planner", "plannerVariableName": "resumen", "items": [ { "label": "Pendiente", "value": "{{pendiente}}", "color": "eab308" }, { "label": "En curso", "value": "{{en_curso}}", "color": "3b82f6" }, { "label": "Cerrada", "value": "{{cerrada}}", "color": "22c55e" } ] } }

Limits

Pitfall: in the ModularIoT setup, category templates resolve only when Data Source is Planner. With static data (only possible by importing a document with staticData) or a query with no rows, {{pendiente}} shows as 0. The title and unit always resolve.

LimitAlternative
Reads only the first rowPivot the query: one column per category
Categories are fixed. A new state does not appear on its ownAdd the column and the category
The legend is a list. There are no cards per categoryAdd a Stat Card per state with the same variable and Value {{pendiente}}
Clicking a part does not filter other widgetsUse a dashboard select filter
The Data Provider tab has no static JSON editorUse a saved query
color is hex without # (eab308)In Chart v2, customColors takes #
Category templates do not read {{filter.…}}Put the filter value in the title
Last updated on