Here is a flow to draw temperature and humidity charts from a database (I use mysql). I'm sure it is copied from another forum thread.
[{"id":"91271c26.3a1e4","type":"inject","z":"80222fae.fe94c","name":"Define SQL","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"select * from mytable","payload":"","payloadType":"date","x":150,"y":80,"wires":[["dddef08a.ed0728"]]},{"id":"dddef08a.ed0728","type":"mysql","z":"80222fae.fe94c","mydb":"e92693f3.b0bc68","name":"db","x":310,"y":80,"wires":[["3ad73d6c.b2d132"]]},{"id":"3ad73d6c.b2d132","type":"function","z":"80222fae.fe94c","name":"Format","func":"let labels = [];\nlet data = [];\nlet data1 = [];\nlet msg1 = {};\n\nmsg.payload.forEach(myFunction);\n\nfunction myFunction(item, index) { \n data.push(item.temperature);\n labels.push(item.timestamp);\n data1.push(item.humidity);\n}\n\nmsg.payload = [{\n \"series\": [\"Temperature\"],\n \"data\": [data],\n \"labels\": labels \n}];\n\nmsg1.payload = [{\n \"series\": [\"Humidity\"],\n \"data\": [data1],\n \"labels\": labels \n}];\n\nreturn [msg, msg1];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":80,"wires":[["92bac926.09f5"],["229af107.7b51d6"]]},{"id":"92bac926.09f5","type":"ui_chart","z":"80222fae.fe94c","name":"","group":"a6e358b.672ffa8","order":13,"width":"7","height":"4","label":"temp (°C)","chartType":"line","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":620,"y":60,"wires":[[]]},{"id":"229af107.7b51d6","type":"ui_chart","z":"80222fae.fe94c","name":"","group":"a6e358b.672ffa8","order":13,"width":"7","height":"4","label":"humidity (%)","chartType":"line","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":630,"y":100,"wires":[[]]},{"id":"e92693f3.b0bc68","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"test","tz":"","charset":"UTF8"},{"id":"a6e358b.672ffa8","type":"ui_group","name":"Demo","tab":"4e528085.a1bfa","order":1,"disp":true,"width":"20","collapse":false},{"id":"4e528085.a1bfa","type":"ui_tab","name":"Demo","icon":"dashboard","order":2,"disabled":false,"hidden":false}]