Dynamic chart Label disappears in dashboard

Hi,

I'm setting the chart Label (or title) with msg.Lable. It works fine on the first view but it disappears if I move to another dashboard tab and then back again. Any tips on how to make the Label stick?

[
    {
        "id": "edbf92277c2a065b",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "2b8db4ab.e04304",
        "type": "inject",
        "z": "edbf92277c2a065b",
        "name": "redraw",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "#:(file)::chartcontext",
        "payloadType": "global",
        "x": 150,
        "y": 220,
        "wires": [
            [
                "7efed36c.48e5f4"
            ]
        ]
    },
    {
        "id": "7efed36c.48e5f4",
        "type": "ui_chart",
        "z": "edbf92277c2a065b",
        "name": "",
        "group": "a8e4a3.d31edb6",
        "order": 4,
        "width": 6,
        "height": 8,
        "label": "{{msg.Lable}}",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "3",
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 510,
        "y": 220,
        "wires": [
            [
                "36634f37.f603d"
            ]
        ]
    },
    {
        "id": "36634f37.f603d",
        "type": "change",
        "z": "edbf92277c2a065b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(file)::chartcontext",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 710,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "1e888fd86708685d",
        "type": "function",
        "z": "edbf92277c2a065b",
        "name": "function 24",
        "func": "\nmsg.payload = [{ \"series\": [\"Import\", \"Export\"], \"data\": [[235.79999999999998, 233.512, 232.6583, 235.95, 237.32829999999998, 242.2858, 251.37579999999997, 265.2971, 292.8441, 263.03499999999997, 288.89959999999996, 279.2999, 283.404, 310.83979999999997, 250.9633, 237.95099999999996, 274.2608, 315.22479999999996, 388.1537, 386.3937, 387.0035, 378.7631, 316.8872, 316.6381], [144.595, 138.787, 132.7733, 132.495, 132.7733, 139.7308, 150.6208, 168.20209999999997, 168.4441, 145.805, 119.6206, 110.46090000000001, 114.345, 139.7308, 132.7733, 119.91099999999999, 150.6208, 184.98479999999998, 205.7847, 205.7847, 207.45449999999997, 195.0641, 181.88719999999998, 168.9281]], \"labels\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23] }]\nmsg.topic =  \"price0\"\nmsg.Lable =  \"Euro/MWh @\" + msg.now\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 310,
        "y": 260,
        "wires": [
            [
                "7efed36c.48e5f4"
            ]
        ]
    },
    {
        "id": "3150b88f5afb271d",
        "type": "inject",
        "z": "edbf92277c2a065b",
        "name": "",
        "props": [
            {
                "p": "now",
                "v": "",
                "vt": "date"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 150,
        "y": 260,
        "wires": [
            [
                "1e888fd86708685d"
            ]
        ]
    },
    {
        "id": "a8e4a3.d31edb6",
        "type": "ui_group",
        "name": "Chart",
        "tab": "8032fe72.980b98",
        "order": 3,
        "disp": false,
        "width": "6",
        "collapse": false
    },
    {
        "id": "8032fe72.980b98",
        "type": "ui_tab",
        "name": "PnH",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Solved it partially by setting Label to {{Label}} instead of {{msg.Lable}}.
The Label then stick when shifting to other tab and back.
But if I reload the webpage the Label disappears.

But if I reload the webpage the Label disappears.

because the chart label will expect {{whateveryouinput}} and if it does not receive anything, it will be empty.
between "tabs" it will stay because it is a single page that does not reload.

So when you load the page you will need to inject it, you can do this using the ui control node, it can listen for events (load, connect, tab change etc), so upon connect, inject the label (and the values probably)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.