How to show old and current values in same chart

I have a photovoltaic and want to display the generated power of last day and the current values in the same chart. The reason is e.g. - especialla on days like now - to see, at which time I get a power boost and also to compare values to previous day.

  1. Is this possible?

  2. I tried something e.g. with persit-node. Here my last try with error output:

[
    {
        "id": "d1395164b4eec73e",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "3c4d5e6f",
        "type": "ui_chart",
        "z": "d1395164b4eec73e",
        "name": "PV-Verlauf",
        "group": "1234abcd",
        "order": 0,
        "width": 0,
        "height": 0,
        "label": "PV-Verlauf",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "60",
        "removeOlderPoints": "",
        "removeOlderUnit": "1",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ff7f0e",
            "#2ca02c",
            "#d62728",
            "#9467bd",
            "#8c564b",
            "#e377c2",
            "#7f7f7f",
            "#bcbd22"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 770,
        "y": 200,
        "wires": [
            [
                "6384b542aa7b1ae0",
                "fff133a270aad047"
            ]
        ]
    },
    {
        "id": "c231fb8e5b4de12d",
        "type": "mqtt in",
        "z": "d1395164b4eec73e",
        "name": "",
        "topic": "fronius/pv",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "5678efgh",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 320,
        "y": 120,
        "wires": [
            [
                "e975445ac74efe55"
            ]
        ]
    },
    {
        "id": "e975445ac74efe55",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "current",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 160,
        "wires": [
            [
                "3c4d5e6f",
                "373d4c6def9679d0"
            ]
        ]
    },
    {
        "id": "373d4c6def9679d0",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "current",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "msg",
        "x": 960,
        "y": 160,
        "wires": []
    },
    {
        "id": "6ec3ee6932ad7c1a",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "old",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "msg",
        "x": 1210,
        "y": 340,
        "wires": []
    },
    {
        "id": "6384b542aa7b1ae0",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "chart",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1190,
        "y": 200,
        "wires": []
    },
    {
        "id": "fff133a270aad047",
        "type": "delay",
        "z": "d1395164b4eec73e",
        "name": "",
        "pauseType": "rate",
        "timeout": "60",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "60",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": false,
        "outputs": 1,
        "x": 650,
        "y": 340,
        "wires": [
            [
                "34c2d5a4e3aa4532"
            ]
        ]
    },
    {
        "id": "34c2d5a4e3aa4532",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "old",
                "tot": "str"
            },
            {
                "t": "move",
                "p": "payload[0].data[1]",
                "pt": "msg",
                "to": "payload[0].data[0]",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload[0].data[1]",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 910,
        "y": 340,
        "wires": [
            [
                "3c4d5e6f",
                "6ec3ee6932ad7c1a",
                "22b7950217b71371"
            ]
        ]
    },
    {
        "id": "22b7950217b71371",
        "type": "ui_chart",
        "z": "d1395164b4eec73e",
        "name": "PV (old)",
        "group": "1234abcd",
        "order": 0,
        "width": 0,
        "height": 0,
        "label": "PV old",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "60",
        "removeOlderPoints": "",
        "removeOlderUnit": "1",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ff7f0e",
            "#2ca02c",
            "#d62728",
            "#9467bd",
            "#8c564b",
            "#e377c2",
            "#7f7f7f",
            "#bcbd22"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1140,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "1234abcd",
        "type": "ui_group",
        "name": "PV-Anlage",
        "tab": "abcd1234",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "5678efgh",
        "type": "mqtt-broker",
        "name": "mySHS",
        "broker": "192.168.178.51",
        "port": "1883",
        "clientid": "raspi101",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "abcd1234",
        "type": "ui_tab",
        "name": "Dashboard",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

I get the error:

msg : error
"TypeError: oldValue[0].values.data[s].push is not a function"

So perhaps my change-node is wrong:
grafik

Thanks for all comment and help

I'm a little bit further, but I think it is not possible. I get now:
grafik

It is not a fixed timeframe (in this testcase with 1 min) with the two charts :(. Any idea?

My current flow:

[
    {
        "id": "d1395164b4eec73e",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "3c4d5e6f",
        "type": "ui_chart",
        "z": "d1395164b4eec73e",
        "name": "PV-Verlauf",
        "group": "1234abcd",
        "order": 0,
        "width": 0,
        "height": 0,
        "label": "PV-Verlauf",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "60",
        "removeOlderPoints": "",
        "removeOlderUnit": "1",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ff7f0e",
            "#2ca02c",
            "#d62728",
            "#9467bd",
            "#8c564b",
            "#e377c2",
            "#7f7f7f",
            "#bcbd22"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 770,
        "y": 200,
        "wires": [
            [
                "6384b542aa7b1ae0",
                "fff133a270aad047"
            ]
        ]
    },
    {
        "id": "c231fb8e5b4de12d",
        "type": "mqtt in",
        "z": "d1395164b4eec73e",
        "name": "",
        "topic": "fronius/pv",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "5678efgh",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 320,
        "y": 160,
        "wires": [
            [
                "e975445ac74efe55"
            ]
        ]
    },
    {
        "id": "e975445ac74efe55",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "current",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 160,
        "wires": [
            [
                "3c4d5e6f",
                "373d4c6def9679d0"
            ]
        ]
    },
    {
        "id": "373d4c6def9679d0",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "current",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "msg",
        "x": 1120,
        "y": 160,
        "wires": []
    },
    {
        "id": "6ec3ee6932ad7c1a",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "old",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "msg",
        "x": 1130,
        "y": 340,
        "wires": []
    },
    {
        "id": "6384b542aa7b1ae0",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "chart",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1110,
        "y": 220,
        "wires": []
    },
    {
        "id": "fff133a270aad047",
        "type": "delay",
        "z": "d1395164b4eec73e",
        "name": "",
        "pauseType": "rate",
        "timeout": "60",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "60",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": false,
        "outputs": 1,
        "x": 650,
        "y": 340,
        "wires": [
            [
                "34c2d5a4e3aa4532"
            ]
        ]
    },
    {
        "id": "34c2d5a4e3aa4532",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "old",
                "tot": "str"
            },
            {
                "t": "move",
                "p": "payload[0].data[1]",
                "pt": "msg",
                "to": "payload[0].data[0]",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload[0].data[1]",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload[0].series[1]",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 910,
        "y": 340,
        "wires": [
            [
                "6ec3ee6932ad7c1a",
                "22b7950217b71371",
                "3c4d5e6f"
            ]
        ]
    },
    {
        "id": "22b7950217b71371",
        "type": "ui_chart",
        "z": "d1395164b4eec73e",
        "name": "PV (old)",
        "group": "1234abcd",
        "order": 0,
        "width": 0,
        "height": 0,
        "label": "PV old",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "60",
        "removeOlderPoints": "",
        "removeOlderUnit": "1",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ff7f0e",
            "#2ca02c",
            "#d62728",
            "#9467bd",
            "#8c564b",
            "#e377c2",
            "#7f7f7f",
            "#bcbd22"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1140,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "1abefc3de704fb17",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "debug 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 480,
        "y": 400,
        "wires": []
    },
    {
        "id": "23964d6418ae3eba",
        "type": "inject",
        "z": "d1395164b4eec73e",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "old",
        "payload": "0",
        "payloadType": "num",
        "x": 190,
        "y": 220,
        "wires": [
            [
                "1abefc3de704fb17",
                "3c4d5e6f"
            ]
        ]
    },
    {
        "id": "7396a93e06575937",
        "type": "inject",
        "z": "d1395164b4eec73e",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[]",
        "payloadType": "json",
        "x": 170,
        "y": 300,
        "wires": [
            [
                "3c4d5e6f",
                "22b7950217b71371"
            ]
        ]
    },
    {
        "id": "1234abcd",
        "type": "ui_group",
        "name": "PV-Anlage",
        "tab": "abcd1234",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "5678efgh",
        "type": "mqtt-broker",
        "name": "mySHS",
        "broker": "192.168.178.51",
        "port": "1883",
        "clientid": "raspi101",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "abcd1234",
        "type": "ui_tab",
        "name": "Dashboard",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Not sure I fully understand
If you display the stored old data yesterdays

Then to add new data just remove 24 hours form the timestamp of incoming new data.

This example uses data time stamped for midnight last night, not 24 hours different as i have no data from 24 hours ago.
i just remove 24 hours and data received at 3pm today would show up under 3pm yesterday

[{"id":"acd3c31877e13960","type":"ui_button","z":"d1395164b4eec73e","name":"old data","group":"1234abcd","order":2,"width":0,"height":0,"passthru":false,"label":"ad old data","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":640.9999923706055,"y":198.0000057220459,"wires":[["09e8aa098a6b5ed4"]]},{"id":"09e8aa098a6b5ed4","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[{\"series\":[\"Old Power\"],\"data\":[[{\"x\":1695682800000,\"y\":0},{\"x\":1695686400000,\"y\":0},{\"x\":1695690000000,\"y\":0},{\"x\":1695693600000,\"y\":0},{\"x\":1695697200000,\"y\":0},{\"x\":1695700800000,\"y\":0},{\"x\":1695704400000,\"y\":0},{\"x\":1695708000000,\"y\":0},{\"x\":1695711600000,\"y\":0},{\"x\":1695715200000,\"y\":0},{\"x\":1695718800000,\"y\":0},{\"x\":1695722400000,\"y\":0.01},{\"x\":1695726000000,\"y\":0.14},{\"x\":1695729600000,\"y\":0.17},{\"x\":1695733200000,\"y\":0.7},{\"x\":1695736800000,\"y\":0.85},{\"x\":1695740400000,\"y\":0.85},{\"x\":1695744000000,\"y\":0.64},{\"x\":1695747600000,\"y\":0.51},{\"x\":1695751200000,\"y\":0.43},{\"x\":1695754800000,\"y\":0.86},{\"x\":1695758400000,\"y\":0.43},{\"x\":1695762000000,\"y\":0.29},{\"x\":1695765600000,\"y\":0.21},{\"x\":1695769200000,\"y\":0.17},{\"x\":1695772800000,\"y\":0.14},{\"x\":1695776400000,\"y\":0},{\"x\":1695780000000,\"y\":0},{\"x\":1695783600000,\"y\":0},{\"x\":1695787200000,\"y\":0},{\"x\":1695790800000,\"y\":0},{\"x\":1695794400000,\"y\":0},{\"x\":1695798000000,\"y\":0},{\"x\":1695801600000,\"y\":0},{\"x\":1695805200000,\"y\":0},{\"x\":1695808800000,\"y\":0},{\"x\":1695812400000,\"y\":0},{\"x\":1695816000000,\"y\":0},{\"x\":1695819600000,\"y\":0},{\"x\":1695823200000,\"y\":0},{\"x\":1695826800000,\"y\":0},{\"x\":1695830400000,\"y\":0},{\"x\":1695834000000,\"y\":0},{\"x\":1695837600000,\"y\":0},{\"x\":1695841200000,\"y\":0.67},{\"x\":1695844800000,\"y\":0.79},{\"x\":1695848400000,\"y\":0.84},{\"x\":1695852000000,\"y\":0.88}]],\"labels\":[]}]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":820.9999923706055,"y":198.0000057220459,"wires":[["3c4d5e6f"]]},{"id":"3c4d5e6f","type":"ui_chart","z":"d1395164b4eec73e","name":"PV-Verlauf","group":"1234abcd","order":0,"width":0,"height":0,"label":"PV-Verlauf","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"60","removeOlderPoints":"","removeOlderUnit":"1","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22"],"outputs":1,"useDifferentColor":false,"className":"","x":990.9999923706055,"y":198.0000057220459,"wires":[["6384b542aa7b1ae0"]]},{"id":"8d08e21e3af47f2a","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$round($random(), 3)","tot":"jsonata"},{"t":"set","p":"timestamp","pt":"msg","to":"$number($moment().subtract(1 ,\"day\").format(\"x\"))","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"New power","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020.9999923706055,"y":298.0000057220459,"wires":[["3c4d5e6f"]]},{"id":"6384b542aa7b1ae0","type":"debug","z":"d1395164b4eec73e","name":"chart","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1150.9999923706055,"y":198.0000057220459,"wires":[]},{"id":"ece784bd6a17077a","type":"ui_button","z":"d1395164b4eec73e","name":"add new incoming","group":"1234abcd","order":1,"width":0,"height":0,"passthru":false,"label":"add new reading","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":810.9999923706055,"y":298.0000057220459,"wires":[["8d08e21e3af47f2a"]]},{"id":"1234abcd","type":"ui_group","name":"PV-Anlage","tab":"abcd1234","order":1,"disp":true,"width":"6","collapse":false},{"id":"abcd1234","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Thanks @E1cid I think we are on the right way, but it doesn't work now :(.

It seems to be ok, if I look at debug output. The times should be ok, but the chart isn't well. I have no idea what's wrong!?

Here is your improved code, which is closer to the reality:


The time is reduced to 1 min - instead of 1 day for testing.
The inject will provide a value every 5 sec (new data). After 1 min, the output of the chart will be transfered to the input with a new name for the series. So I get well data with two series as an input and the same timeframe, but in my chart I don't have 2 chart lines.

![grafik|331x500](upload://oUY4THom6jZ3R4NhzvYXTCTW2Ss.png)

Current code:

[
    {
        "id": "8a701c96ea9f2909",
        "type": "ui_chart",
        "z": "d1395164b4eec73e",
        "name": "PV-Verlauf",
        "group": "1234abcd",
        "order": 0,
        "width": 0,
        "height": 0,
        "label": "PV-Verlauf",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "60",
        "removeOlderPoints": "",
        "removeOlderUnit": "1",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ff7f0e",
            "#2ca02c",
            "#d62728",
            "#9467bd",
            "#8c564b",
            "#e377c2",
            "#7f7f7f",
            "#bcbd22"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 890,
        "y": 660,
        "wires": [
            [
                "c978733bb177459d",
                "3ccfb9a5a2ae850e"
            ]
        ]
    },
    {
        "id": "8d08e21e3af47f2a",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "change for new data",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$round($random(), 3)",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "timestamp",
                "pt": "msg",
                "to": "$number($moment().subtract(1 ,\"minute\").format(\"x\"))",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "new",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 660,
        "y": 660,
        "wires": [
            [
                "8a701c96ea9f2909"
            ]
        ]
    },
    {
        "id": "c978733bb177459d",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "chart",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 660,
        "wires": []
    },
    {
        "id": "3ccfb9a5a2ae850e",
        "type": "delay",
        "z": "d1395164b4eec73e",
        "name": "",
        "pauseType": "rate",
        "timeout": "60",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "60",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": false,
        "outputs": 1,
        "x": 410,
        "y": 580,
        "wires": [
            [
                "5f2e29a7c869120d"
            ]
        ]
    },
    {
        "id": "5f2e29a7c869120d",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "change for old data",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "old",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload[0].series[0]",
                "pt": "msg",
                "to": "old",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 650,
        "y": 580,
        "wires": [
            [
                "8a701c96ea9f2909",
                "c3cfad7bb9e4bca0"
            ]
        ]
    },
    {
        "id": "c3cfad7bb9e4bca0",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "old",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "msg",
        "x": 1070,
        "y": 580,
        "wires": []
    },
    {
        "id": "983fe8d85b3f4283",
        "type": "inject",
        "z": "d1395164b4eec73e",
        "name": "every 5 sec",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "5",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 450,
        "y": 660,
        "wires": [
            [
                "8d08e21e3af47f2a"
            ]
        ]
    },
    {
        "id": "53e8601545abab1f",
        "type": "inject",
        "z": "d1395164b4eec73e",
        "name": "reset chart",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[]",
        "payloadType": "json",
        "x": 460,
        "y": 740,
        "wires": [
            [
                "8a701c96ea9f2909"
            ]
        ]
    },
    {
        "id": "1234abcd",
        "type": "ui_group",
        "name": "PV-Anlage",
        "tab": "abcd1234",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "abcd1234",
        "type": "ui_tab",
        "name": "Dashboard",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Here is another example
This time i create a sample old data over 24 minutes for testing. it then creates 24 incoming payloads over 24 minutes.
It reads stored chart and appends the new incoming payload to the chart data, setting timestamp to 24 minutes ago. Then sends new chart data to chart, which redraws the chart.

At no time do you need to loop back and create a loop.

[{"id":"acd3c31877e13960","type":"ui_button","z":"d1395164b4eec73e","name":"old data","group":"1234abcd","order":2,"width":0,"height":0,"passthru":false,"label":"add old data","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"stop","payloadType":"str","topic":"topic","topicType":"msg","x":102.00000381469727,"y":123.00000333786011,"wires":[["09e8aa098a6b5ed4","aacb7c989775f11e","30b593da2878a4dc"]]},{"id":"09e8aa098a6b5ed4","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t   $fiveminsago := $number($moment().subtract(24,\"minute\").format(\"x\"));\t   [\t       {\t           \"series\": [\"Old Power\", \"New Power\"],\t           \"data\": [\t               [\t                   [\t                       0,\t                       1,\t                       2,\t                       3,\t                       4,\t                       5,\t                       6,\t                       7,\t                       8,\t                       9,\t                       10,\t                       11,\t                       12,\t                       13,\t                       14,\t                       15,\t                       16,\t                       17,\t                       18,\t                       19,\t                       20,\t                       21,\t                       22,\t                       23\t                   ].{\"x\": $fiveminsago + ($ * 60000), \"y\": $round($random(), 3)}            \t               ],[]       \t           ]  \t       }\t   ]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":322.00000381469727,"y":123.00000333786011,"wires":[["3c4d5e6f"]]},{"id":"aacb7c989775f11e","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"0","op1type":"str","op2type":"str","duration":"-1","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":132.00000381469727,"y":223.0000033378601,"wires":[["8d08e21e3af47f2a"]]},{"id":"30b593da2878a4dc","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"stop","op1type":"nul","op2type":"str","duration":"24","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":132.00000381469727,"y":283.0000033378601,"wires":[["a28ec7fe4cacc7ab"]]},{"id":"3c4d5e6f","type":"ui_chart","z":"d1395164b4eec73e","name":"PV-Verlauf","group":"1234abcd","order":0,"width":0,"height":0,"label":"PV-Verlauf","chartType":"line","legend":"true","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"100","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22"],"outputs":1,"useDifferentColor":false,"className":"","x":552.0000038146973,"y":123.00000333786011,"wires":[["6384b542aa7b1ae0","c6db3e133e3ff792"]]},{"id":"a28ec7fe4cacc7ab","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":302.00000381469727,"y":283.0000033378601,"wires":[["aacb7c989775f11e"]]},{"id":"8d08e21e3af47f2a","type":"change","z":"d1395164b4eec73e","name":"incoming mqtt payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"$round($random(), 3)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":342.00000381469727,"y":223.0000033378601,"wires":[["2a48fed91cb81590"]]},{"id":"2a48fed91cb81590","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"temp","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"chartdata","tot":"flow"},{"t":"set","p":"payload[0].data[1]","pt":"msg","to":"$append(\t    $$.payload[0].data[1], \t    [{\"x\": $number($moment().subtract(24, \"minute\").format(\"x\")),\"y\": $$.temp}]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":562.0000038146973,"y":223.0000033378601,"wires":[["3c4d5e6f","f9ec617765271a03"]]},{"id":"6384b542aa7b1ae0","type":"debug","z":"d1395164b4eec73e","name":"chart","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":692.0000038146973,"y":143.0000033378601,"wires":[]},{"id":"c6db3e133e3ff792","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"chartdata","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":692.0000038146973,"y":63.00000333786011,"wires":[[]]},{"id":"f9ec617765271a03","type":"debug","z":"d1395164b4eec73e","name":"debug 343","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":612.0000038146973,"y":283.0000033378601,"wires":[]},{"id":"1234abcd","type":"ui_group","name":"PV-Anlage","tab":"abcd1234","order":1,"disp":true,"width":"6","collapse":false},{"id":"abcd1234","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

The triggers are there just to start incoming data and stop it after 24 minutes

After running for 20 minutes

1 Like

Boah - what a coding! @E1cid you are a huge expert :). I'll never find such a code, but I can read it.

Your example works, but didn't update the "Old power" to the last period. I found the way. :slight_smile:

But one thing may be messy: My function node to store current values. (I can't use the output of the chart, because there the time is adjusted to the past.)

I'm sure you now how to transfer my function node to the change node "change for new data", or a seperate one.

I have in general trouble using JSONate. I found this description and this simulator, but it seems to be different the usage in Node-Red. e.g. your expression $number($moment().format("x")) will not work inside the simulator and the functions are not mentioned in the description.

Here is now my working flow, just reduced to a timeframe of 1 minute:

[
    {
        "id": "8a701c96ea9f2909",
        "type": "ui_chart",
        "z": "d1395164b4eec73e",
        "name": "PV-Verlauf",
        "group": "1234abcd",
        "order": 0,
        "width": 0,
        "height": 0,
        "label": "PV-Verlauf",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "60",
        "removeOlderPoints": "",
        "removeOlderUnit": "1",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#ff7f0e",
            "#2ca02c",
            "#d62728",
            "#9467bd",
            "#8c564b",
            "#e377c2",
            "#7f7f7f",
            "#bcbd22"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 910,
        "y": 720,
        "wires": [
            [
                "c978733bb177459d"
            ]
        ]
    },
    {
        "id": "c978733bb177459d",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "chart",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 720,
        "wires": []
    },
    {
        "id": "5f2e29a7c869120d",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "change old data to latest",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "Old power",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "(\t   [\t       {\t           \"series\": [\"Old Power\", \"New Power\"],\t           \"data\": [\t               [],\t               []       \t           ]  \t       }\t   ]\t)",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload[0].data[0]",
                "pt": "msg",
                "to": "old",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "old",
                "pt": "flow",
                "to": "[]",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 610,
        "y": 640,
        "wires": [
            [
                "8a701c96ea9f2909",
                "c3cfad7bb9e4bca0"
            ]
        ]
    },
    {
        "id": "c3cfad7bb9e4bca0",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "old",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 640,
        "wires": []
    },
    {
        "id": "983fe8d85b3f4283",
        "type": "inject",
        "z": "d1395164b4eec73e",
        "name": "every 5 sec",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "timestamp",
                "v": "$number($moment().format(\"x\"))",
                "vt": "jsonata"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "5",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "New power",
        "payload": "$round($random(), 3)",
        "payloadType": "jsonata",
        "x": 230,
        "y": 720,
        "wires": [
            [
                "c81038ead8d5b188"
            ]
        ]
    },
    {
        "id": "53e8601545abab1f",
        "type": "inject",
        "z": "d1395164b4eec73e",
        "name": "reset chart",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[]",
        "payloadType": "json",
        "x": 220,
        "y": 780,
        "wires": [
            [
                "8a701c96ea9f2909"
            ]
        ]
    },
    {
        "id": "c1a991f3a8115cd3",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "init chart",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "(\t   $fiveminsago := $number($moment().subtract(1,\"minute\").format(\"x\"));\t   [\t       {\t           \"series\": [\"Old Power\", \"New Power\"],\t           \"data\": [\t               [\t                   [\t                       0,\t                       1,\t                       2,\t                       3,\t                       4,\t                       5,\t                       6,\t                       7,\t                       8,\t                       9,\t                       10,\t                       11\t                   ].{\"x\": $fiveminsago + ($ * 60000), \"y\": $round($random(), 3)}            \t               ],[]       \t           ]  \t       }\t   ]\t)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 660,
        "y": 580,
        "wires": [
            [
                "8a701c96ea9f2909",
                "40c6c0e3ffcb57eb"
            ]
        ]
    },
    {
        "id": "5fb141bc640dce0d",
        "type": "switch",
        "z": "d1395164b4eec73e",
        "name": "",
        "property": "old",
        "propertyType": "flow",
        "rules": [
            {
                "t": "null"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 410,
        "y": 600,
        "wires": [
            [
                "c1a991f3a8115cd3"
            ],
            [
                "5f2e29a7c869120d"
            ]
        ]
    },
    {
        "id": "40c6c0e3ffcb57eb",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "init",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 580,
        "wires": []
    },
    {
        "id": "c81038ead8d5b188",
        "type": "function",
        "z": "d1395164b4eec73e",
        "name": "save value",
        "func": "let old = flow.get(\"old\") || [];\n\nlet value = {x:msg.timestamp, y:msg.payload};\nold.push(value);\nflow.set(\"old\",old);\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 410,
        "y": 720,
        "wires": [
            [
                "8d08e21e3af47f2a",
                "91ca458babbf9511"
            ]
        ]
    },
    {
        "id": "8d08e21e3af47f2a",
        "type": "change",
        "z": "d1395164b4eec73e",
        "name": "change for new data",
        "rules": [
            {
                "t": "set",
                "p": "timestamp",
                "pt": "msg",
                "to": "$number($moment().subtract(1 ,\"minute\").format(\"x\"))",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "New Power",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 654,
        "y": 716,
        "wires": [
            [
                "8a701c96ea9f2909",
                "717ec4894c0aeea8"
            ]
        ]
    },
    {
        "id": "9f734376fdca9d9b",
        "type": "inject",
        "z": "d1395164b4eec73e",
        "name": "every minute",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "60",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 240,
        "y": 600,
        "wires": [
            [
                "5fb141bc640dce0d"
            ]
        ]
    },
    {
        "id": "717ec4894c0aeea8",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "time",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "timestamp",
        "targetType": "msg",
        "statusVal": "timestamp",
        "statusType": "auto",
        "x": 864,
        "y": 796,
        "wires": []
    },
    {
        "id": "91ca458babbf9511",
        "type": "debug",
        "z": "d1395164b4eec73e",
        "name": "time",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "timestamp",
        "targetType": "msg",
        "statusVal": "timestamp",
        "statusType": "auto",
        "x": 670,
        "y": 800,
        "wires": []
    },
    {
        "id": "1234abcd",
        "type": "ui_group",
        "name": "PV-Anlage",
        "tab": "494ffd2f5ab44ab2",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "494ffd2f5ab44ab2",
        "type": "ui_tab",
        "name": "Dashboard",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

BTW: How can I post the flow in one line? I read this post, but the link for description of how to post a flow is broken.

Then you would create starting stored data for 48 minutes and add comparison data using last 24 minutes, changing timestamps by -24 minutes.

Then every time data comes in add to both data arrays, i also limit their lengths.

[{"id":"deacfb12474e9f47","type":"ui_button","z":"d1395164b4eec73e","name":"old data","group":"1234abcd","order":2,"width":0,"height":0,"passthru":false,"label":"add old data","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"stop","payloadType":"str","topic":"topic","topicType":"msg","x":140,"y":160,"wires":[["23b3b9d74037861f"]]},{"id":"23b3b9d74037861f","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t   $fiveminsago := $number(\t       $moment().subtract(48,\"minute\").format(\"x\")\t   );\t   [\t       {\t           \"series\": [\"Live PV\", \"Comparison PV\"],\t           \"data\": [\t               [\t                   [\t                       0,\t                       1,\t                       2,\t                       3,\t                       4,\t                       5,\t                       6,\t                       7,\t                       8,\t                       9,\t                       10,\t                       11,\t                       12,\t                       13,\t                       14,\t                       15,\t                       16,\t                       17,\t                       18,\t                       19,\t                       20,\t                       21,\t                       22,\t                       23,\t                       24,\t                       25,\t                       26,\t                       27,\t                       28,\t                       29,\t                       30,\t                       31,\t                       32,\t                       33,\t                       34,\t                       35,\t                       36,\t                       37,\t                       38,\t                       39,\t                       40,\t                       41,\t                       42,\t                       43,\t                       44,\t                       45,\t                       46,\t                       47\t                   ].{\t                       \"x\": $fiveminsago + ($ * 60000),\t                       \"y\": $round($random(), 3)\t                   }            \t               ],\t               []\t           ]\t       }\t    ]\t)","tot":"jsonata"},{"t":"set","p":"payload[0].data[1]","pt":"msg","to":"$$.payload[0].data[0][[-24..-1]].{\"x\": $number($moment($.x).subtract(24, \"minute\").format(\"x\")), \"y\": $.y}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":160,"wires":[["1245c5b9fb2a1132","a49433400584ca4c"]]},{"id":"1245c5b9fb2a1132","type":"ui_chart","z":"d1395164b4eec73e","name":"PV-Verlauf","group":"1234abcd","order":0,"width":0,"height":0,"label":"PV-Verlauf","chartType":"line","legend":"true","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"100","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22"],"outputs":1,"useDifferentColor":false,"className":"","x":590,"y":160,"wires":[["8df4c9aeda6418ba","590e35b8abbaf585"]]},{"id":"a49433400584ca4c","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"0","op1type":"str","op2type":"str","duration":"-1","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":170,"y":260,"wires":[["dd5a7e4be5c2aaa5"]]},{"id":"625128cf5805ea96","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"temp","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"chartdata","tot":"flow"},{"t":"set","p":"payload[0].data[1]","pt":"msg","to":"$append(\t    $$.payload[0].data[1], \t    [{\"x\": $number($moment().subtract(24, \"minute\").format(\"x\")),\"y\": $$.temp}][[-24..-1]]\t)","tot":"jsonata"},{"t":"set","p":"payload[0].data[0]","pt":"msg","to":"$append(\t   $$.payload[0].data[0],\t   [{ \"x\": $millis(),\t           \"y\": $$.temp\t       }\t   ][[-48..-1]] \t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":260,"wires":[["1245c5b9fb2a1132","c16d3a79b92cc180"]]},{"id":"8df4c9aeda6418ba","type":"debug","z":"d1395164b4eec73e","name":"chart","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":200,"wires":[]},{"id":"590e35b8abbaf585","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"chartdata","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":100,"wires":[[]]},{"id":"dd5a7e4be5c2aaa5","type":"change","z":"d1395164b4eec73e","name":"incoming mqtt payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"$round($random(), 3)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":260,"wires":[["625128cf5805ea96"]]},{"id":"c16d3a79b92cc180","type":"debug","z":"d1395164b4eec73e","name":"debug 343","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":320,"wires":[]},{"id":"1234abcd","type":"ui_group","name":"PV-Anlage","tab":"abcd1234","order":1,"disp":true,"width":"12","collapse":false,"className":""},{"id":"abcd1234","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Can also start it with out full data.

[{"id":"1882200e2f591cda","type":"inject","z":"d1395164b4eec73e","name":"reset","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":90,"y":60,"wires":[["5c2308587af05ba5"]]},{"id":"5c2308587af05ba5","type":"ui_button","z":"d1395164b4eec73e","name":"","group":"39236f77681f6d72","order":2,"width":0,"height":0,"passthru":true,"label":"Reset","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":230,"y":60,"wires":[["4a60ce664d26b40b"]]},{"id":"4a60ce664d26b40b","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"json"},{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":60,"wires":[["d088c81af7e7496e","b97e707e8ba23f75"]]},{"id":"d088c81af7e7496e","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-1","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":180,"y":340,"wires":[["e80a53c4828c0a28"]]},{"id":"b97e707e8ba23f75","type":"ui_chart","z":"d1395164b4eec73e","name":"PV-Verlauf","group":"39236f77681f6d72","order":0,"width":0,"height":0,"label":"PV-Verlauf","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22"],"outputs":1,"useDifferentColor":false,"className":"","x":610,"y":240,"wires":[["710461b234ada76d","7582b114ef1c428c"]]},{"id":"eecb9db36db02643","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"timestamp","pt":"msg","to":"","tot":"date"},{"t":"set","p":"offset_period","pt":"msg","to":"120000","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"\t\t   [\t       {\t           \"series\": [\"Live PV\", \"Comparison PV\"],\t           \"data\": [\t               [\t                   {\t                       \"x\": $$.timestamp,\t                       \"y\": 0\t                   }\t               ],\t               [\t                   {\t                       \"x\": $$.timestamp - $$.offest_period,\t                       \"y\": 0\t                   }\t               ]\t           ]\t       }\t    ]\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":240,"wires":[["b97e707e8ba23f75","d088c81af7e7496e"]]},{"id":"e80a53c4828c0a28","type":"change","z":"d1395164b4eec73e","name":"incoming mqtt payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"$round($random(), 3)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":340,"wires":[["8470ab8f7f1c1dc0"]]},{"id":"8470ab8f7f1c1dc0","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"temp","tot":"msg"},{"t":"set","p":"timestamp","pt":"msg","to":"","tot":"date"},{"t":"set","p":"offset_period","pt":"msg","to":"120000","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"chartdata","tot":"flow"},{"t":"set","p":"payload[0].data[1]","pt":"msg","to":"$append(\t    $$.payload[0].data[1], \t    [\t        {\t            \"x\": $$.timestamp - $$.offset_period,\t            \"y\": $$.temp\t        }\t    ]\t)[$.x > $$.timestamp - $$.offset_period * 2]","tot":"jsonata"},{"t":"set","p":"payload[0].data[0]","pt":"msg","to":"$append(\t   $$.payload[0].data[0],\t   [\t       { \t           \"x\": $$.timestamp,\t           \"y\": $$.temp\t       }\t   ]\t)[$.x > $$.timestamp - $$.offset_period * 2]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":340,"wires":[["b97e707e8ba23f75","21e6fb5d80bd1e9c"]]},{"id":"710461b234ada76d","type":"debug","z":"d1395164b4eec73e","name":"chart","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":280,"wires":[]},{"id":"7582b114ef1c428c","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"chartdata","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":180,"wires":[[]]},{"id":"6dc2dbe3657109d1","type":"ui_button","z":"d1395164b4eec73e","name":"old data","group":"39236f77681f6d72","order":2,"width":0,"height":0,"passthru":false,"label":"add old data","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"stop","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":240,"wires":[["eecb9db36db02643"]]},{"id":"21e6fb5d80bd1e9c","type":"debug","z":"d1395164b4eec73e","name":"debug 343","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":400,"wires":[]},{"id":"39236f77681f6d72","type":"ui_group","name":"PV-Anlage","tab":"abcd1234","order":1,"disp":true,"width":"12","collapse":false,"className":""},{"id":"abcd1234","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Added input variables to change timing, change msg.offset_period in both change nodes (in milliseconds).
Fixed limiting arrays using timestamp rather than array count, allows input message at any time rate.

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