Yes I made it wrong, it is bar chart and not line sorry.
The CSV is
01-06-2024;evt r�elle;9;18�785;1;18�432
02-06-2024;evt r�elle;11;18�785;2;18�432
CSV column as you proposed
date,,HP,,HC
and the expected output (but that I am not able to code completely), this is static data only.
Your last flow was very close, it just need to make all HP data in the first array, and all HC in the second array
msg.payload = [
{
"series": ["HP", "HC"],
"data": [[9,11],[1,2]],
"labels": ["01-06-2024", "02-06-2024"]
}
];
return msg;
[
{
"id": "83c3799b1c851f40",
"type": "inject",
"z": "7f455c807e8e067e",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 170,
"y": 1760,
"wires": [
[
"7d785165f1c9eb88"
]
]
},
{
"id": "7d785165f1c9eb88",
"type": "template",
"z": "7f455c807e8e067e",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "01-06-2024;evt r�elle;9;18�785;0;18�432\n02-06-2024;evt r�elle;9;18�785;1;18�432\n",
"output": "str",
"x": 310,
"y": 1760,
"wires": [
[
"08072baccbcad56b"
]
]
},
{
"id": "08072baccbcad56b",
"type": "csv",
"z": "7f455c807e8e067e",
"name": "",
"sep": ";",
"hdrin": "",
"hdrout": "none",
"multi": "mult",
"ret": "\\n",
"temp": "date,,HP,,HC",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 440,
"y": 1760,
"wires": [
[
"9295367f0335e171"
]
]
},
{
"id": "9295367f0335e171",
"type": "function",
"z": "7f455c807e8e067e",
"name": "function 157",
"func": "//msg.payload =Object.keys(msg.payload[0]);\n//return msg;\n\nmsg.payload = [\n {\n \"labels\": msg.payload.map(obj => obj.date),\n \"series\": Object.keys(msg.payload[0]).slice(1),\n \"data\":msg.payload.map(obj => [obj.HP,obj.HC])\n }\n]\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 1760,
"wires": [
[
"907aea81164f131f",
"e1a8b48642b5c44e"
]
]
},
{
"id": "907aea81164f131f",
"type": "debug",
"z": "7f455c807e8e067e",
"name": "debug 2557",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 780,
"y": 1760,
"wires": []
},
{
"id": "e1a8b48642b5c44e",
"type": "ui_chart",
"z": "7f455c807e8e067e",
"name": "",
"group": "cc53c59073725950",
"order": 3,
"width": 0,
"height": 0,
"label": "chart",
"chartType": "bar",
"legend": "false",
"xformat": "Date-Month-Year",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "86400",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 750,
"y": 1820,
"wires": [
[]
]
},
{
"id": "cc53c59073725950",
"type": "ui_group",
"name": "Forecast de demain",
"tab": "10b4df16bc5e110d",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "10b4df16bc5e110d",
"type": "ui_tab",
"name": "Remote App",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]