I built the screen a foreman on an injection-moulding line looks at when handing over. After an eight-hour shift it goes to the next crew, and what they need is not one thing. Did uptime clear the target, where did shots per hour dip, which press and which hour did the scrap pile up in, did the mould temperature ever leave its set point. Put that in one table and nobody reads it.
So five charts of different kinds went on one screen. Every value comes from state. There is not a single number embedded in the screen definition.

A gauge colours its bands
84% uptime is not just 84%. This line's target is 88%, so 84% is a number that has to be explained at handover. The gauge says that in colour.
{
"type": "gauge",
"value": "{{uptime}}",
"min": 0, "max": 100,
"labelFormat": "{value}%",
"segments": [
{ "from": 0, "to": 70, "color": "{{theme.color.error}}" },
{ "from": 70, "to": 88, "color": "{{theme.color.warning}}" },
{ "from": 88, "to": 100, "color": "{{theme.color.success}}" }
]
}
The boundaries in segments are that factory's rule. Change 88 and the place where the colour splits moves with it. labelFormat is not a state binding but this widget's label format pattern, and its default is {value}. That is why it has single braces; written with two it is read as a binding, so this is an easy place to trip.
A bar chart takes datasets whole
Bars showing shots per hour alongside the target. The data goes in as two pieces.
"data": {
"labels": "{{hours}}",
"datasets": "{{series}}"
}
series looks like this.
[
{ "label": "Good", "data": [812, 848, 861, 803, 774, 690, 822, 802] },
{ "label": "Target", "data": [820, 820, 820, 820, 820, 820, 820, 820] }
]
Each set has a label and data, and colours come from the widget's colors array in order. To add another set, push one more object into the state array and leave the screen definition alone. If the server changes how many sets it sends, it draws as is.
The bar at 11 is noticeably low, and that connects to the heatmap that comes next.
A heatmap takes the 2-D array as it is
Scrap rate seen as press (rows) by hour (columns). The data is an array of arrays, and the row and column names are given separately.
{
"type": "heatmap",
"data": "{{scrapGrid}}",
"rowLabels": "{{presses}}",
"columnLabels": "{{hours}}",
"showValues": true,
"colorRange": {
"low": "{{theme.color.primaryContainer}}",
"high": "{{theme.color.error}}"
}
}
Give colorRange just two colours and it interpolates between them. The 11 o'clock cell in the P-4 row comes out darkest at 6.2, and that is the hour the bar dipped. What the foreman tells the next crew comes out of these two cells.
Tapping a cell should report what was tapped. The onCellTap event carries row, column and value.
"onCellTap": {
"type": "state", "action": "set", "binding": "pick",
"value": "{{presses[event.row]}} · {{hours[event.column]}}:00 — {{event.value}} % scrap"
}
event.row and event.column arrive as indexes. The names do not. So the index goes back into the label array to pull the name out.
This content requires Developer or above
Sign in and upgrade your plan to continue reading.
View Plans