you would also set the db return to output the span and time in correct names for chart, and order by time. some thing like this
"SELECT span AS y, time As x FROM 'temp_log'.'access' WHERE room = 'heatingroom' AND position = 'bufferTank' AND direction = 'span' ORDER BY time LIMIT 1000;"
you can then feed that directly to a change or function or template node to format the chart array. The output of each chart can then feed the next chart, you can then limit each chart to week, day, hour.
e.g.
[{"id":"f5142b09.9b2248","type":"inject","z":"bf9e1e33.030598","name":"dat from db in correct format","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"x\":1662769858618,\"y\":5.41},{\"x\":1662770158623,\"y\":3.91},{\"x\":1662770458619,\"y\":0.91},{\"x\":1662770758624,\"y\":6.25},{\"x\":1662771058619,\"y\":2.62},{\"x\":1662771358624,\"y\":7.34},{\"x\":1662771658624,\"y\":7.61},{\"x\":1662771958620,\"y\":1.56},{\"x\":1662772258625,\"y\":7.83},{\"x\":1662772558626,\"y\":3.63},{\"x\":1662772858626,\"y\":3.49},{\"x\":1662773158626,\"y\":9.51},{\"x\":1662774658629,\"y\":3.56},{\"x\":1662774958630,\"y\":2.01},{\"x\":1662775258630,\"y\":9.12},{\"x\":1662775558631,\"y\":9.7},{\"x\":1662775858630,\"y\":7.89},{\"x\":1662776158631,\"y\":1.71},{\"x\":1662776458631,\"y\":7.91},{\"x\":1662776758632,\"y\":8.34},{\"x\":1662777058633,\"y\":7.83},{\"x\":1662777358634,\"y\":0.5},{\"x\":1662777658635,\"y\":8.98},{\"x\":1662777958637,\"y\":9.25},{\"x\":1662778258637,\"y\":3.94},{\"x\":1662778558639,\"y\":7.58},{\"x\":1662778858639,\"y\":4.59},{\"x\":1662779158640,\"y\":1.73},{\"x\":1662779458644,\"y\":5.95},{\"x\":1662779758645,\"y\":0.16},{\"x\":1662780058645,\"y\":5.65},{\"x\":1662780358645,\"y\":6.63},{\"x\":1662780658646,\"y\":0.77},{\"x\":1662780958647,\"y\":3.25},{\"x\":1662781258647,\"y\":0.16},{\"x\":1662781558648,\"y\":2.54},{\"x\":1662781858649,\"y\":6.07},{\"x\":1662782158650,\"y\":2.64},{\"x\":1662782458651,\"y\":0.07},{\"x\":1662782758652,\"y\":5.37},{\"x\":1662783058653,\"y\":8.98},{\"x\":1662783358654,\"y\":6.82},{\"x\":1662783658653,\"y\":8.27},{\"x\":1662783958654,\"y\":6.45},{\"x\":1662784258654,\"y\":6.87},{\"x\":1662784558655,\"y\":2.05},{\"x\":1662784858656,\"y\":6.49},{\"x\":1662785158656,\"y\":0.04},{\"x\":1662785458656,\"y\":1.71},{\"x\":1662785758656,\"y\":1.11},{\"x\":1662786058656,\"y\":6.54},{\"x\":1662786358657,\"y\":6.45},{\"x\":1662786658657,\"y\":6.79},{\"x\":1662786958658,\"y\":6.01},{\"x\":1662787258665,\"y\":4.66},{\"x\":1662787558663,\"y\":9.85},{\"x\":1662787858665,\"y\":4.75},{\"x\":1662788158664,\"y\":3.1},{\"x\":1662788458665,\"y\":2.36},{\"x\":1662788758665,\"y\":4.95},{\"x\":1662789058665,\"y\":4.54},{\"x\":1662789358666,\"y\":7.72},{\"x\":1662789658667,\"y\":2.24},{\"x\":1662789958668,\"y\":0},{\"x\":1662790258669,\"y\":1.2},{\"x\":1662790558670,\"y\":2.17},{\"x\":1662790858670,\"y\":2.97},{\"x\":1662791158671,\"y\":0.19},{\"x\":1662791458672,\"y\":4.66},{\"x\":1662791758673,\"y\":5.62},{\"x\":1662792058674,\"y\":8.16},{\"x\":1662792358674,\"y\":3.02},{\"x\":1662792658675,\"y\":3.68},{\"x\":1662792958675,\"y\":9.35},{\"x\":1662793258676,\"y\":0.5},{\"x\":1662793558677,\"y\":9.64},{\"x\":1662793858677,\"y\":0.34},{\"x\":1662794158678,\"y\":2.51},{\"x\":1662794458677,\"y\":0.71},{\"x\":1662794758678,\"y\":3.31},{\"x\":1662795058678,\"y\":7.86},{\"x\":1662795358678,\"y\":9.89},{\"x\":1662795658678,\"y\":6.04},{\"x\":1662795958679,\"y\":5.12},{\"x\":1662796258678,\"y\":2.84},{\"x\":1662796558686,\"y\":3.59},{\"x\":1662796858684,\"y\":5.74},{\"x\":1662797158685,\"y\":8.08},{\"x\":1662797458686,\"y\":9.92},{\"x\":1662797758687,\"y\":8.22},{\"x\":1662798058687,\"y\":3.84},{\"x\":1662798358688,\"y\":1.35},{\"x\":1662798658690,\"y\":2.87},{\"x\":1662798958689,\"y\":8.83},{\"x\":1662799258688,\"y\":6.5},{\"x\":1662799558689,\"y\":2.53},{\"x\":1662799858689,\"y\":2.89},{\"x\":1662800158690,\"y\":8.7}]","payloadType":"json","x":240,"y":3680,"wires":[["541ba449.a0034c"]]},{"id":"541ba449.a0034c","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t {\t \"series\":[\"temp\"],\t \"data\":[ [$$.payload]],\t \"labels\":[\"temp\"]\t }\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":3680,"wires":[["efd2c82a.d9935"]]},{"id":"efd2c82a.d9935","type":"ui_chart","z":"bf9e1e33.030598","name":"","group":"2d4fe667.28f8ba","order":13,"width":0,"height":0,"label":"week","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"4","removeOlderPoints":"1000","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":300,"y":3760,"wires":[["2acea977.40afce","445cb618.031938"]]},{"id":"2acea977.40afce","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":3760,"wires":[]},{"id":"445cb618.031938","type":"ui_chart","z":"bf9e1e33.030598","name":"","group":"2d4fe667.28f8ba","order":14,"width":0,"height":0,"label":"day","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"60","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":380,"y":3800,"wires":[["bd4a6478.817348","2acea977.40afce"]]},{"id":"bd4a6478.817348","type":"ui_chart","z":"bf9e1e33.030598","name":"","group":"2d4fe667.28f8ba","order":15,"width":0,"height":0,"label":"hour","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"12","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":480,"y":3840,"wires":[["2acea977.40afce"]]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]