Skip to Content
DashboardsLearnChoose a widget

Choose a widget

For: implementers. Setup: widget and setting names are the ModularIoT ones; the rest applies to any setup.

You will learn to:

  • find the widget that matches a design;
  • know whether a widget reads one row or all rows of its query;
  • choose between Stacked Stat and a pie or bar chart.

From design to widget

Find what your design shows in the first column.

The design showsWidgetcomponentId
A large number, with an icon or a titleStat Cardstat_icon
A number with a color status (green, yellow, red)Status Cardstat_status
A KPI per state and a 100% bar split by stateStacked Stat, type Barstat_stacked
The same, as a donutStacked Stat, type Donutstat_stacked
Progress toward a goalProgress Stat, Progress or Circular Statstat_progress, percentage_value, stat_circular
A number with a small line. In ModularIoT the line points are typed in the settingsSparkline Statstat_sparkline
A number compared with the previous periodDetailed Statstat_detailed
Bars per category, with axesChart v2, Cartesian family, bar representationchart_v2
A ranking: the top N by number of eventsChart v2, Horizontal Barschart_v2
A daily or monthly trendChart v2, line representation, X-Axis is a Datechart_v2
Bars stacked by month and stateChart v2, several bar representations with Stackedchart_v2
Bars and a line in another unitChart v2, bar + line, Dual Y-Axischart_v2
A pie with the distribution by categoryChart v2, Pie familychart_v2
A value within a range (speedometer)Chart v2, Gauge familychart_v2
A list to review row by rowData Table V2data_table_v2
One card per row, with badgesData Listdata_list
Text or a section titleText Cardtext_card
Click a chart to filter a tableNot available. Use a dashboard select filter—

The names are the ones in the ModularIoT UI. The componentId is what the document stores and what other setups use.

One row or all rows

Each widget reads its query in one of two ways. Write the query to match.

ReadsWidgetsThe query returns
Only the first rowText Card, Info Card, every Stat, Progress, Stacked Stat, Chart v2 GaugeOne row. One column per number the widget shows.
All rowsData Table, Data Table V2, Data List, Chart v2 Cartesian and PieOne row per item: per table row, per bar or per slice.

Stats, Stacked Stat and Text Card use templates: {{pendiente}} is replaced by the value of the pendiente column in the first row. The Gauge reads its representation’s column in the first row. If the query returns more rows, the widget ignores them.

Pitfall: if a query returns one row per state (estado, cantidad), a Stacked Stat only sees the first state. Write the query with one column per state. Queries for widgets shows how.

Stacked Stat, pie or bars

All three show the parts of a total.

Stacked StatChart v2 PieChart v2 Bars
CategoriesFixed, typed in the settingsOne per query rowOne per query row
Color of each categoryFixed, one per categoryFrom the color list, in row orderOne per series; the bars of a series share a color
Query shapeOne row, one column per categoryOne row per category: name column + value columnOne row per category: X-axis column + one column per series
100% barYes. Each part is its value over the sumNoNo. For 100%, compute percentages in the query
KPI shown per categoryYes, in the legendOn hover. Slice labels show only the nameWith Labels on the representation
Click filters another widgetNoNoNo
Stacked StatChart v2 PieChart v2 Bars, one color per state
Stacked StatPieBars with one color per state

Use Stacked Stat when you know the states in advance and each has a fixed color. Use the pie or bars when the categories change with the data.

Colors per category in Chart v2

Chart v2 assigns one color per series:

ChartWhat gets a color
Bars or linesEach representation (series). A series color is customColors[i], where i is its position. If missing, the chart’s color list at that position. In ModularIoT, once a representation has a color, that list is customColors: give every representation a color.
PieEach slice, in row order, from the chart’s color list: customColors when colorPalette is custom and the list is not empty; otherwise the colorPalette palette. ModularIoT always saves custom.
Any, with color rulesA point or slice whose numeric value matches the rule. A rule does not compare the category name.

In the ModularIoT setup, the color picker of each representation writes customColors[i]. A pie has one representation:

If youThe pie shows
Leave the representation color aloneEach slice in a default palette color, in row order
Pick a color for the representationEvery slice in that color

To fix one color per state in a pie, edit the document (Import and export):

  1. Export the dashboard.
  2. In the widget, check that colorPalette is "custom" and write one color per slice in customColors, in row order.
  3. Import the file.
  4. Sort the query rows in a fixed order. If a state has no rows, the colors shift.

For bars with one color per state: return one column per state and create one representation per column, each with its color. See Queries for widgets.

Next

Queries for widgets: the exact query shape for each widget.

Last updated on