As I pointed out earlier this could be done in the sql query.
here is an example, replace the change node with your sqlite node.
[{"id":"e5025b32b4af5f4b","type":"ui_form","z":"bf9e1e33.030598","name":"Data points","label":"","group":"1e17cd0b.862863","order":0,"width":0,"height":0,"options":[{"label":"Period: today","value":"period/today","type":"checkbox","required":false,"rows":null},{"label":"Period: yesterday","value":"period/yesterday","type":"checkbox","required":false,"rows":null},{"label":"Period: this week","value":"period/week","type":"checkbox","required":false,"rows":null},{"label":"Node 201 Battery","value":"node201/dev04","type":"checkbox","required":false,"rows":null},{"label":"Node 201 Temperature","value":"node201/dev50","type":"checkbox","required":false,"rows":null},{"label":"Node 201 RSSI","value":"node201/dev02","type":"checkbox","required":false,"rows":null},{"label":"Node 220 Battery","value":"node220/dev04","type":"checkbox","required":false,"rows":null},{"label":"Node 220 Temperature","value":"node220/dev48","type":"checkbox","required":false,"rows":null},{"label":"Node 220 Humidity","value":"node220/dev49","type":"checkbox","required":false,"rows":null},{"label":"Node 220 RSSI","value":"node220/dev02","type":"checkbox","required":false,"rows":null}],"formValue":{"period/today":false,"period/yesterday":false,"period/week":false,"node201/dev04":false,"node201/dev50":false,"node201/dev02":false,"node220/dev04":false,"node220/dev48":false,"node220/dev49":false,"node220/dev02":false},"payload":"","submit":"Submit","cancel":"Cancel","topic":"","topicType":"str","splitLayout":false,"className":"","x":135,"y":1367,"wires":[["edd704eac37c28c1"]]},{"id":"edd704eac37c28c1","type":"function","z":"bf9e1e33.030598","name":"SQL","func":"// This will handle any device and any attribute as long as it is in the DB\nvar Week = 604800000 ; //7 Days\nvar Day = 86400000 ; // 1 Days\nvar d = new Date();\nvar epoch = d.getTime();\nvar fromdate = epoch - Day;\nvar enddate = epoch;\nvar output = [];\n\nfor (const property in msg.payload) {\n if (msg.payload.hasOwnProperty(property)) {\n //output.push({ payload: property + \" has value \"+msg.payload[property] });\n if (msg.payload[property]) {\n var parts = property.split(\"/\");\n if (parts[0]===\"period\") {\n switch (parts[1]) {\n case \"today\":\n fromdate = epoch-Day;\n enddate = epoch;\n break;\n case \"yesterday\":\n fromdate = epoch-2*Day;\n enddate = epoch-Day;\n break;\n case \"week\":\n fromdate = epoch-Week;\n enddate = epoch;\n break;\n }\n } else {\n output.push({ \n device : property,\n topic: \"SELECT epoch AS x, value AS y FROM seedhouse WHERE Node='\"+parts[0]+\"' AND Sensor='\"+parts[1]+\"' AND epoch >= \" + fromdate + \" AND epoch <= \" + enddate + \" ORDER BY epoch\" });\n }\n }\n }\n}\n\noutput[output.length-1].complete=true;\n\nreturn [ output ];\n\n//msg.topic = \"SELECT * FROM sensor_data WHERE device='growatt' AND sensor='power' AND epoch >= \" + fromdate + \" AND epoch <= \" + epoch ;\n//return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":1420,"wires":[["c161f790bb333a62","ad0ab92f.ae57c8"]]},{"id":"c161f790bb333a62","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":1360,"wires":[]},{"id":"ad0ab92f.ae57c8","type":"change","z":"bf9e1e33.030598","name":"for testing replace with sqlite node","rules":[{"t":"set","p":"payload","pt":"msg","to":"[{\"x\":1652034981107,\"y\":$random()*10+93.99},{\"x\":1652035947269,\"y\":$random()*10+96.13}]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1480,"wires":[["1168162739bfaf7d"]]},{"id":"1168162739bfaf7d","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"device","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":618,"y":1421,"wires":[["63e36a68b9ad13f8","8dbf9c5f2b6c9767"]]},{"id":"63e36a68b9ad13f8","type":"function","z":"bf9e1e33.030598","name":"Prep","func":"const labels = [];\nconst data = [];\nconst series = [];\n\nfor(const key in msg.payload){\n labels.push(key);\n data.push(msg.payload[key]);\n series.push(key);\n}\n\nmsg.payload =[\n {\n labels,\n data,\n series\n }]\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":807,"y":1423,"wires":[["77ecb32dc5a5b5c1","01cbcea724a124aa"]]},{"id":"8dbf9c5f2b6c9767","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":703.75,"y":1345,"wires":[]},{"id":"77ecb32dc5a5b5c1","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":963.75,"y":1385,"wires":[]},{"id":"01cbcea724a124aa","type":"ui_chart","z":"bf9e1e33.030598","name":"Chart","group":"bd903d6.d9fc7c","order":0,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":" H:m a","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"604800","cutout":"","useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":830,"y":1540,"wires":[[]]},{"id":"457076cc.a92f18","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{ \"series\": [\"A\", \"B\", \"C\"], \"data\": [ [{ \"x\": 1504029632890, \"y\": 5 }, { \"x\": 1504029636001, \"y\": 4 }, { \"x\": 1504029638656, \"y\": 2 } ], [{ \"x\": 1504029633514, \"y\": 6 }, { \"x\": 1504029636622, \"y\": 7 }, { \"x\": 1504029639539, \"y\": 6 } ], [{ \"x\": 1504029634400, \"y\": 7 }, { \"x\": 1504029637959, \"y\": 7 }, { \"x\": 1504029640317, \"y\": 7 } ] ], \"labels\": [\"\"] }]","payloadType":"json","x":780,"y":1280,"wires":[["77ecb32dc5a5b5c1"]]},{"id":"b9636e89d32ffa37","type":"inject","z":"bf9e1e33.030598","name":"Reset chart","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"[]","payloadType":"json","x":165,"y":1543,"wires":[["01cbcea724a124aa"]]},{"id":"1e17cd0b.862863","type":"ui_group","name":"Selection","tab":"1e3fe400.0baf5c","order":1,"disp":true,"width":"5"},{"id":"bd903d6.d9fc7c","type":"ui_group","name":"Report","tab":"1e3fe400.0baf5c","order":2,"disp":true,"width":"18"},{"id":"1e3fe400.0baf5c","type":"ui_tab","name":"Reports","icon":"dashboard","order":9}]
Then there would be no need to format the data to x,y as it would be returned that way already.
ps added a order by to query just incase there is data in database that is out of sync.