How to read saved data from json code to ui-chart

[
    {
        "id": "d3bbd1c0.07cec",
        "type": "inject",
        "z": "03dd6101fc31dadf",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "900",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "start",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 3520,
        "wires": [
            [
                "b1edd399.9488e8"
            ]
        ]
    },
    {
        "id": "b1edd399.9488e8",
        "type": "template",
        "z": "03dd6101fc31dadf",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "AGVName,Date,Time,B1C1,B1C2,B1Temp,Current,SOC\n107102,2022/2/8,00:04.8,3.427,3.477,33,192.7,61\n107102,2022/2/8,00:11.7,8.449,3.503,33,193.2,61\n107102,2022/2/8,00:18.5,3.466,3.524,33,192.9,62\n107102,2022/2/8,00:25.3,3.474,3.536,33,192.7,62\n107102,2022/2/8,00:32.2,3.481,3.545,33,193,62\n107102,2022/2/8,00:39.0,3.361,3.384,33,-20.9,63\n107102,2022/2/8,00:45.9,3.341,3.365,33,-13.8,63\n107102,2022/2/8,00:52.7,3.326,3.343,33,-14.2,63\n107102,2022/2/8,00:59.6,3.312,3.326,33,-14.7,63\n107102,2022/2/8,01:06.5,3.306,3.313,33,-13.8,63\n107102,2022/2/8,01:13.3,3.299,3.305,33,-15.9,63\n107102,2022/2/8,01:20.2,3.291,3.291,33,-18.9,63\n107102,2022/2/8,01:27.0,3.286,3.283,33,-15.7,63\n107102,2022/2/8,01:33.9,3.288,3.284,33,-13.4,63\n107102,2022/2/8,01:40.7,3.288,3.283,33,-12.4,63\n107102,2022/2/8,01:47.6,3.281,3.27,33,-19.9,63\n107102,2022/2/8,01:54.5,3.279,3.267,33,-17.1,63\n107102,2022/2/8,02:01.3,3.278,3.265,33,-17.7,63\n107102,2022/2/8,02:08.1,3.276,3.262,33,-19.1,63\n107102,2022/2/8,02:15.0,3.276,3.262,33,-16.3,63\n107102,2022/2/8,02:22.6,3.279,3.267,33,-13.2,63\n107102,2022/2/8,02:29.4,3.278,3.265,33,-13.8,63\n107102,2022/2/8,02:36.3,3.278,3.267,33,-12.8,63\n107102,2022/2/8,02:43.1,3.277,3.264,33,-14,63\n107102,2022/2/8,02:50.0,3.277,3.264,33,-14,63\n107102,2022/2/8,02:56.8,3.276,3.263,33,-12.2,63\n107102,2022/2/8,03:03.7,3.279,3.267,33,-11.4,63\n107102,2022/2/8,03:10.5,3.267,3.248,33,-10.2,63\n107102,2022/2/8,03:17.3,3.277,3.265,33,-10.4,50\n107102,2022/2/8,03:24.2,3.277,3.265,33,-10,70\n107102,2022/2/8,03:31.0,3.269,3.254,33,-20.9,80\n107102,2022/2/8,03:37.8,3.272,3.257,33,-16.9,85\n107102,2022/2/8,03:44.6,3.273,3.259,33,-14.2,63\n107102,2022/2/8,03:51.5,3.268,3.252,33,-22.4,63\n",
        "output": "str",
        "x": 280,
        "y": 3480,
        "wires": [
            [
                "bc6a4158.0d8508"
            ]
        ]
    },
    {
        "id": "bc6a4158.0d8508",
        "type": "csv",
        "z": "03dd6101fc31dadf",
        "name": "csv",
        "sep": ",",
        "hdrin": true,
        "hdrout": "all",
        "multi": "mult",
        "ret": "\\n",
        "temp": "AGV,Date,Time,B1C1,B1C2,B1Temp, Current,SOC",
        "skip": "0",
        "strings": true,
        "include_empty_strings": "",
        "include_null_values": "",
        "x": 410,
        "y": 3480,
        "wires": [
            [
                "c0ba397e.0b979",
                "d37e1783.2a496",
                "1af8e604842ba26c"
            ]
        ]
    },
    {
        "id": "c0ba397e.0b979",
        "type": "debug",
        "z": "03dd6101fc31dadf",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 3420,
        "wires": []
    },
    {
        "id": "d37e1783.2a496",
        "type": "function",
        "z": "03dd6101fc31dadf",
        "name": "graph generate",
        "func": "let payload=msg.payload;\n\nlet data = [[],[],[],[],[]];\nfor(let i=0;i<payload.length;i++){\n    let date = payload[i].Date.split(\"/\");\n    date[1] = date[1].padStart(2,\"0\");\n    date[2] = date[2].padStart(2,\"0\");\n    date = date.join(\"-\")\n    let time = payload[i].Time.split(\".\");\n    time[1] =time[1].padStart(2,\"0\");\n    time = time.join(\":\");\n     time = new Date(date+\"T\"+time);\n    data[0].push({\"x\": time, \"y\": payload[i].B1C1});\n    data[1].push({\"x\": time, \"y\": payload[i].B1C2});\n    data[2].push({\"x\": time, \"y\": payload[i].B1Temp});\n    data[3].push({\"x\": time, \"y\": payload[i].Current});\n    data[4].push({\"x\": time, \"y\": payload[i].SOC});\n}\nlet labels = msg.columns.split(\",\").slice(3);\nmsg.soc=data[4][data[4].length-1].y\nnode.warn(msg.soc)\nmsg.payload=[{\n\"series\": labels,\n\"data\":data,\n\"labels\": labels\n}];\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 600,
        "y": 3480,
        "wires": [
            [
                "1f0031ad.1f2e0e",
                "8c626d16.8159c8"
            ]
        ]
    },
    {
        "id": "1f0031ad.1f2e0e",
        "type": "ui_chart",
        "z": "03dd6101fc31dadf",
        "name": "",
        "group": "2b3d76b5.53b31a",
        "order": 5,
        "width": 0,
        "height": 0,
        "label": "Time Graph Test-1",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#400000",
            "#ff8000",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 830,
        "y": 3480,
        "wires": [
            []
        ]
    },
    {
        "id": "8c626d16.8159c8",
        "type": "debug",
        "z": "03dd6101fc31dadf",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 3420,
        "wires": []
    },
    {
        "id": "1af8e604842ba26c",
        "type": "file",
        "z": "03dd6101fc31dadf",
        "name": "",
        "filename": "C:\\Users\\issam\\Desktop\\N.csv",
        "filenameType": "str",
        "appendNewline": true,
        "createDir": false,
        "overwriteFile": "false",
        "encoding": "none",
        "x": 570,
        "y": 3560,
        "wires": [
            [
                "7c3953324060eb54"
            ]
        ]
    },
    {
        "id": "0690b2d1ebe1f203",
        "type": "inject",
        "z": "03dd6101fc31dadf",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "start",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 3760,
        "wires": [
            [
                "427a2cbf21bbd978"
            ]
        ]
    },
    {
        "id": "427a2cbf21bbd978",
        "type": "file in",
        "z": "03dd6101fc31dadf",
        "name": "",
        "filename": "C:\\Users\\issam\\Desktop\\N.csv",
        "filenameType": "str",
        "format": "lines",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": true,
        "x": 450,
        "y": 3780,
        "wires": [
            [
                "ce27d6a12b852043"
            ]
        ]
    },
    {
        "id": "ee517bdae3941ee9",
        "type": "debug",
        "z": "03dd6101fc31dadf",
        "name": "debug 44",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 800,
        "y": 3820,
        "wires": []
    },
    {
        "id": "7c3953324060eb54",
        "type": "debug",
        "z": "03dd6101fc31dadf",
        "name": "de8888",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 840,
        "y": 3560,
        "wires": []
    },
    {
        "id": "ce27d6a12b852043",
        "type": "json",
        "z": "03dd6101fc31dadf",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 650,
        "y": 3740,
        "wires": [
            [
                "cfbc2be351cedbd3",
                "ee517bdae3941ee9"
            ]
        ]
    },
    {
        "id": "cfbc2be351cedbd3",
        "type": "ui_chart",
        "z": "03dd6101fc31dadf",
        "name": "",
        "group": "2b3d76b5.53b31a",
        "order": 5,
        "width": 0,
        "height": 0,
        "label": "Time Graph Test-2 read",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#400000",
            "#ff8000",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 850,
        "y": 3740,
        "wires": [
            []
        ]
    },
    {
        "id": "2b3d76b5.53b31a",
        "type": "ui_group",
        "name": "Default",
        "tab": "16ec7043.17f57",
        "order": 1,
        "disp": true,
        "width": "12",
        "collapse": false
    },
    {
        "id": "16ec7043.17f57",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard"
    }
]

The json node is not suitable for this task, you could either do it manually in a function node or the node node-red-contrib-csvtojson (node) - Node-RED (nodered.org) should be also working

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