Chart Node is not working correctly

Hello...
I've been using chart for reading .csv files and It was working pretty nice BUT at some point it just stops the reading for the csv file. It's wierd 'cause I can send to chart older csv files but recently files are just not working on chart.

var chartData = {
    series: [],
    data: [ ],   
    labels: []  
};
for (var i = 1; i <= 6; i++) {
    var columnName = "T" + i;

    chartData.series.push(columnName);

    var seriesData = [];

    msg.payload.forEach(function (row) {
        var dataPoint = {
            x: row["Fecha - Hora"],
            y: parseFloat(row[columnName])  
        };

        seriesData.push(dataPoint);
    });

    chartData.data.push(seriesData);
}

msg.payload = [chartData];
return msg;

This is the code I'm using for sending csv array to chart.

Can anyone help me to solve this issue?

Please edit you post and correct the code , as it needs to be posted correctly

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

Also it is very difficult to diagnose issues without example input.
Copy first 5 lines of csv file and paste them in a template node, then create a example flow using template rather than file read node. Paste example flow here as shown above.
How to import/export a flow

Thanks for the advice

[
    {
        "id": "4483d1e2393def58",
        "type": "tab",
        "label": "Example",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "7c3db8cccb61bd31",
        "type": "template",
        "z": "4483d1e2393def58",
        "name": "GOOD EXAMPLE",
        "field": "payload",
        "fieldType": "msg",
        "format": "javascript",
        "syntax": "mustache",
        "template": "[{\"Fecha - Hora\":\"10/03/2024 00:08\",\"T1\":81.43,\"T2\":81.62,\"T3\":92.05,\"T4\":89.41,\"T5\":89.9,\"T6\":95.97},{\"Fecha - Hora\":\"10/03/2024 00:18\",\"T1\":82.18,\"T2\":81.57,\"T3\":93.98,\"T4\":90.53,\"T5\":90.3,\"T6\":98.36},{\"Fecha - Hora\":\"10/03/2024 00:28\",\"T1\":82.53,\"T2\":81.53,\"T3\":94.54,\"T4\":90.18,\"T5\":90.35,\"T6\":95.94},{\"Fecha - Hora\":\"10/03/2024 00:38\",\"T1\":82.39,\"T2\":81.29,\"T3\":93.96,\"T4\":91.13,\"T5\":90.52,\"T6\":97.98},{\"Fecha - Hora\":\"10/03/2024 00:48\",\"T1\":81.36,\"T2\":81.27,\"T3\":92.74,\"T4\":90.03,\"T5\":90.27,\"T6\":96.05}]",
        "output": "json",
        "x": 590,
        "y": 280,
        "wires": [
            [
                "9149406bd5d212ba"
            ]
        ]
    },
    {
        "id": "9149406bd5d212ba",
        "type": "function",
        "z": "4483d1e2393def58",
        "name": "CHART",
        "func": "var chartData = {\n    series: [],\n    data: [],   \n    labels: []  \n};\nfor (var i = 1; i <= 6; i++) {\n    var columnName = \"T\" + i;\n\n    chartData.series.push(columnName);\n\n    var seriesData = [];\n\n    msg.payload.forEach(function (row) {\n        var dataPoint = {\n            x: row[\"Fecha - Hora\"],\n            y: parseFloat(row[columnName])  \n        };\n\n        seriesData.push(dataPoint);\n    });\n\n    chartData.data.push(seriesData);\n}\n\nmsg.payload = [chartData];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 840,
        "y": 300,
        "wires": [
            [
                "1a8b752a8e8ade35"
            ]
        ]
    },
    {
        "id": "1a8b752a8e8ade35",
        "type": "ui_chart",
        "z": "4483d1e2393def58",
        "name": "",
        "group": "be853d70bd1c97e3",
        "order": 58,
        "width": 0,
        "height": 0,
        "label": "chart",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "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": 1010,
        "y": 300,
        "wires": [
            [
                "fc9f138bc88a5075"
            ]
        ]
    },
    {
        "id": "70a86e8370030de9",
        "type": "inject",
        "z": "4483d1e2393def58",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 280,
        "wires": [
            [
                "7c3db8cccb61bd31"
            ]
        ]
    },
    {
        "id": "fc9f138bc88a5075",
        "type": "debug",
        "z": "4483d1e2393def58",
        "name": "debug 28",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1180,
        "y": 300,
        "wires": []
    },
    {
        "id": "17a19b2d7441ec82",
        "type": "template",
        "z": "4483d1e2393def58",
        "name": "BAD EXAMPLE",
        "field": "payload",
        "fieldType": "msg",
        "format": "javascript",
        "syntax": "mustache",
        "template": "[{ \"Fecha - Hora\": \"13/03/2024 00:39\", \"T1\": 83.96, \"T2\": 85.68, \"T3\": 92.86, \"T4\": 90.95, \"T5\": 94.53, \"T6\": 102.05 }, { \"Fecha - Hora\": \"13/03/2024 00:49\", \"T1\": 84.05, \"T2\": 86.88, \"T3\": 92.26, \"T4\": 89.94, \"T5\": 97.81, \"T6\": 104.82 }, { \"Fecha - Hora\": \"13/03/2024 00:59\", \"T1\": 85.82, \"T2\": 88.95, \"T3\": 92.94, \"T4\": 90.51, \"T5\": 97.16, \"T6\": 103.42 }, { \"Fecha - Hora\": \"13/03/2024 01:09\", \"T1\": 85.42, \"T2\": 87.53, \"T3\": 94.57, \"T4\": 90.39, \"T5\": 96.59, \"T6\": 102.27 }]",
        "output": "json",
        "x": 580,
        "y": 320,
        "wires": [
            [
                "9149406bd5d212ba"
            ]
        ]
    },
    {
        "id": "4c6b50ec4aa7c0ba",
        "type": "inject",
        "z": "4483d1e2393def58",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 320,
        "wires": [
            [
                "17a19b2d7441ec82"
            ]
        ]
    },
    {
        "id": "ef694fcbabe30cfc",
        "type": "comment",
        "z": "4483d1e2393def58",
        "name": "Note:",
        "info": "Here I have a \"good example\" that was\nfrom a .csv from 3 days ago that works correctly \nand a \"Bad example\" from a .csv from today",
        "x": 270,
        "y": 140,
        "wires": []
    },
    {
        "id": "be853d70bd1c97e3",
        "type": "ui_group",
        "name": "Pruebas de Gráficas",
        "tab": "c92c58d9672674b5",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "c92c58d9672674b5",
        "type": "ui_tab",
        "name": "Prueba",
        "icon": "dashboard",
        "order": 11,
        "disabled": false,
        "hidden": false
    }
]

Here I have a "good example" that was from a .csv from 3 days ago that works correctly and a "Bad example" from a .csv from today.
I still don't know what's going on, I see everything is the same but It just doesn't work.

The issue is your date format
10/03/2024 the chart sees as October the 3rd
13/03/2024 the chart sees as the 13 month, which does not exist and therefore is a bad date, therefore does not display.

So you need to send 03/13/2024 00:00.
fix how you store csv file date ( best use timestamp milliseconds or ISO 8601) or alter function code to deal with date format.

Alter chart x format to custom and type in MM you will see month is 10 not 3.

Thank you so much
I'm new in this language I've been forced to learn quickly. Appreciate the help, once again, Thank you.

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