Node-RED Dashboard State Trail Chart

1.0.2 · active · verified Wed Apr 22

node-red-contrib-ui-state-trail is a Node-RED dashboard UI node that renders a Gantt-type chart to visualize the historical changes of a state over a configurable time period. It is designed for displaying single-line state timelines, such as the operational status (on/off, running/stopped) of a device or process. The current stable version is 1.0.2. As a Node-RED contrib node, it typically receives updates on an as-needed basis rather than a strict release cadence, focusing on stability and new features. Key differentiators include its ability to accept both simple and timestamped historical data, customizable legend display (showing all states, current states, or latest state), state aggregation for performance, and optional persistent data storage when Node-RED's context storage is properly configured. It supports string, number, and boolean state types, which are treated distinctly.

Common errors

Warnings

Install

Imports

Quickstart

This Node-RED flow demonstrates sending a simple current state, an array of historical states, and a control message to dynamically change the chart's display period for the 'State Trail' UI node. Replace `flow_id` and `dashboard_group` with actual IDs from your Node-RED instance.

[
    {
        "id": "inject_current_state",
        "type": "inject",
        "name": "Send 'running'",
        "topic": "",
        "payload": "running",
        "payloadType": "str",
        "repeat": "5",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 160,
        "y": 100,
        "wires": [
            ["state_trail_node"]
        ]
    },
    {
        "id": "inject_historical_data",
        "type": "inject",
        "name": "Send Historical Data",
        "topic": "",
        "payload": "[
    {state: \"stopped\", timestamp: Date.now() - 3600000},
    {state: \"running\", timestamp: Date.now() - 1800000},
    {state: \"error\", timestamp: Date.now() - 600000}
]",
        "payloadType": "json_ata",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 1,
        "x": 190,
        "y": 160,
        "wires": [
            ["state_trail_node"]
        ]
    },
    {
        "id": "inject_control_period",
        "type": "inject",
        "name": "Set Period to 10 min",
        "topic": "",
        "payload": "{\"period\":600000}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 2,
        "x": 190,
        "y": 220,
        "wires": [
            ["state_trail_node"]
        ]
    },
    {
        "id": "state_trail_node",
        "type": "ui_state_trail",
        "z": "flow_id", // Replace with your flow ID
        "group": "dashboard_group", // Replace with your dashboard group ID
        "name": "My State Trail",
        "label": "Process State",
        "order": 0,
        "width": 0,
        "height": 2,
        "period": 3600000, // Default to 1 hour
        "period_unit": "hour",
        "combine": true,
        "states": [
            { "state": "running", "label": "Running" },
            { "state": "stopped", "label": "Stopped" },
            { "state": "error", "label": "Error" },
            { "state": true, "label": "Active" },
            { "state": false, "label": "Inactive" }
        ],
        "legend": 0,
        "ticks": 6,
        "x": 450,
        "y": 100,
        "wires": []
    }
]

view raw JSON →