Skip to Content

Chart v2

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

Bar, line, scatter, pie and gauge charts. One chart can mix bars and lines, stack series and use two Y axes.

Data it reads

FamilyReadsQuery shape
Cartesian (bars, lines, scatter)All rows, in their orderOne row per X-axis category. One column per series
PieAll rows, in their orderOne row per slice: name column + value column
GaugeThe first rowOne row with a numeric column

The chart does not sort or group rows: use ORDER BY and GROUP BY in the query. An empty or non-numeric value leaves a gap.

Variants

VariantSettingsQuery shapeScreenshot
BarsCartesian family, one Bar representationestado, cantidadBars
Horizontal bars (top N)Horizontal Bars, Labelsresponsable, cantidad with ORDER BY cantidad DESC LIMIT 5Horizontal bars
Stacked barsOne representation per state, all with Stackedmes, pendiente, en_curso, cerradaStacked bars
Line with dateLine representation, Smooth, X-Axis is a Datefecha, cantidadLine
Bars + line, dual axisDual Y-Axis; the line on axis Rmes, solicitudes, horasDual axis
PiePie familyestado, cantidadPie
GaugeGauge familyOne row: cerradas_pctGauge
One color per stateX-Axis Column estado. One representation per state, all with Stacked, Labels and their own color. Show Legend offOne row per state. Only its state’s column has a valueOne color per state
Color rulesColors & Rules: greater than 10 → red, up to 10 → greenresponsable, atrasadasColor rules
PalettecolorPalette: "warm" (document only)mes + three columnsPalette

Bars

Bars Pendiente 12, En curso 7, Cerrada 30

Horizontal bars

Top 5 owners as horizontal bars with labels

The first row is at the top. Sort the query from highest to lowest.

Stacked bars

Bars stacked by month with three states

Stacked bars show counts. For 100% bars, compute percentages in the query.

Line

Smoothed line by day with the buttons Todo, 7D, 30D, 3M, 6M, 1A

With X-Axis is a Date, the chart shows buttons to filter by range (All, 7D, 30D, 3M, 6M, 1Y; in Spanish Todo … 1A). Labels show as dd-mm-yyyy. The axis is still a category axis: it does not sort or fill days.

Dual axis

Request bars on the left axis and a line of hours on the right

Pie

Pie (donut) with Pendiente, En curso and Cerrada

Gauge

Gauge from 0 to 100 at 61.2

The scale goes from 0 to 100. Use a percentage.

One color per state

Yellow, blue and green bars, one per state, with their value on top

SELECT estado, IF(estado = 'pendiente', COUNT(*), NULL) AS pendiente, IF(estado = 'en_curso', COUNT(*), NULL) AS en_curso, IF(estado = 'cerrada', COUNT(*), NULL) AS cerrada FROM `my-project.operations.solicitudes` GROUP BY estado ORDER BY CASE estado WHEN 'pendiente' THEN 1 WHEN 'en_curso' THEN 2 ELSE 3 END

With Stacked, each bar is centered on its category. Colors follow the representation order: the first color belongs to the first representation.

To show In progress instead of en_curso, convert it in the query: CASE estado WHEN 'en_curso' THEN 'In progress' … END AS estado.

Color rules

Red bars for owners with more than 10 delays and green for the rest

Palette

Bars with the warm palette

The UI has no palette selector and always saves colorPalette: "custom". A named palette (default, cool, warm, monochrome, pastel, vivid) is used only if you write it in the document (Import and export). The palette is lost when you save the widget settings in the UI.

Settings

SectionSettingDocument keyEffect
GeneralTitletitleAccepts templates
GeneralChart FamilychartFamily (cartesian, pie, gauge)Switching to Pie or Gauge keeps only the first representation
Data MappingX-Axis Column (Pie: Category Column)xAxisColumnCategory column. Not in Gauge
Data MappingRepresentations › typerepresentations[].type (bar, line, scatter)Cartesian only
Data MappingRepresentations › column and labelcolumnKey, labelThe label is the legend name. Accepts templates
Data MappingRepresentations › colorcustomColors[i]Color of series i
Data MappingSmooth (line)smoothSmooth curve
Data MappingStacked (line or bar)stackedEvery series with Stacked shares one stack
Data MappingLabels (bar)showLabelsValue on each bar
Data MappingL / R (with dual axis)yAxisIndex (0, 1)Axis of the series
AppearanceX-Axis Label, Y-Axis LabelxAxisLabel, yAxisLabelAxis names
AppearanceRight Y-Axis LabelyAxisLabelRightDual axis only. Does not accept templates
AppearanceShow LegendshowLegendLegend at the bottom
AppearanceHorizontal BarshorizontalOnly when every representation is a bar
AppearanceDual Y-AxisdualYAxisSecond axis on the right
AppearanceX-Axis is a DatexAxisDateFormatThe switch saves month. It only turns on the date axis and the range buttons
Colors & RulesValue Color RulesvalueColorRules.rules[]Color of a point by its value
TooltipTemplatetooltipTemplateText on hover. Uses {{row.column}}
Data ProviderData Source: Planner or StaticdataMode, plannerVariableName, rowsIn static mode, rows go in rows

Colors

WhatColor
A series (bars or lines)customColors[i], with #. If missing, the chart’s color list at that position
A pie sliceThe chart’s color list, in row order
A point that matches a ruleThe rule’s color

Pitfall: in a pie, if you pick a color for its only representation, every slice takes that color. Do not pick a color in a pie. For a fixed color per state, use One color per state or a Stacked Stat.

Once a representation has a color, the chart’s color list becomes customColors. Give every representation a color. The ones without a color repeat others’ colors.

Rule operators

FieldValues
Operator=, !=, contains, !contains, >, <, >=, <=
ValueNumber or text
ColorHex without #

Rules compare each point’s numeric value, not the category name or another column. > and >= rules are checked from highest to lowest value, then < and <= from lowest to highest. The first match wins. On a line, the rule colors the point, not the stroke.

Tooltip

With the field empty, the tooltip shows every series at the category. With a template, it shows the text of the row under the cursor:

{{row.responsable}}: {{row.atrasadas}} late

The template has no access to the series name or to filters.

Full example

{ "componentId": "chart_v2", "config": { "title": "Solicitudes por mes y estado", "chartFamily": "cartesian", "xAxisColumn": "mes", "representations": [ { "columnKey": "pendiente", "label": "Pendiente", "type": "bar", "stacked": true }, { "columnKey": "en_curso", "label": "En curso", "type": "bar", "stacked": true }, { "columnKey": "cerrada", "label": "Cerrada", "type": "bar", "stacked": true } ], "colorPalette": "custom", "customColors": ["#eab308", "#3b82f6", "#22c55e"], "showLegend": true, "horizontal": false, "xAxisLabel": "", "yAxisLabel": "", "dataMode": "planner", "plannerVariableName": "por_mes" } }

In a Cartesian chart, always include customColors, even as []: without that key, the widget fails.

Limits

LimitAlternative
Clicking a bar or slice does not filter other widgetsUse a dashboard select filter
No color per category in the pieOne color per state or Stacked Stat
The gauge goes from 0 to 100Send a percentage
The date axis does not sort or fill days without dataSort and fill the days in the query
A date without time (2026-01-01) is read as UTC midnight and shows one day earlier in time zones west of UTC, such as America/SantiagoSend the date with a time: 2026-01-01T12:00:00
The palette and the initial range (defaultDateRange) are lost when you save the settings in the UIImport them again in the document
The value label of the longest bar can be cut off at the edge—
Last updated on