How can I show two different data in one graph

Hi;
How can I show two different data in one graph. Thank you in advance for your help

[{"id":"be4ba5fc5add8b7d","type":"tab","label":"Flow 17","disabled":false,"info":"","env":[]},{"id":"c18eb38d29190239","type":"mysql","z":"be4ba5fc5add8b7d","mydb":"496de392.ca2cbc","name":"","x":1070,"y":480,"wires":[["1f5876dfd3a7be0e"]]},{"id":"d26f66511c6d7ddb","type":"ui_chart","z":"be4ba5fc5add8b7d","name":"","group":"2f70fd7d67ed6a37","order":11,"width":30,"height":5,"label":"","chartType":"line","legend":"true","xformat":"Y-M-D / HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":true,"colors":["#1f96ea","#0bf933","#f97d10","#2ca02c","#37f20d","#fb0909","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1390,"y":480,"wires":[["6a057478727c289e"]]},{"id":"1f5876dfd3a7be0e","type":"function","z":"be4ba5fc5add8b7d","name":"","func":"var sec_sens1 = flow.get( \"secim1\" ) || false ;\nvar sec_sens  = flow.get( \"secim\"  ) || false ; \n\nvar data1 = [];\nvar data = [];\nvar Zaman = [];\nvar Zaman1 = [];\n\nmsg.payload.forEach(function(value) {\n    \n data.push( value[ sec_sens1 ] );  // temp or hum choice \n Zaman1.push( value['Zaman'] );   // time data   /*  Exp:  Zaman = Time   */\n \n});\n\n\nmsg.payload = [{\n    \n series: [ \"\"+ sec_sens + \"   \"   + sec_sens1 +\" verisi\"],\n data: [ data ],\n labels: Zaman1\n\n}];\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":480,"wires":[["d26f66511c6d7ddb"]]},{"id":"f2010022525e821e","type":"ui_button","z":"be4ba5fc5add8b7d","name":"","group":"2f70fd7d67ed6a37","order":5,"width":3,"height":2,"passthru":false,"label":"Get","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"date","topic":"query","topicType":"str","x":530,"y":740,"wires":[["7b156ef5d6e1546b","61bc08b1b3802736"]]},{"id":"7b156ef5d6e1546b","type":"function","z":"be4ba5fc5add8b7d","name":"sensor_1 get_data","func":"\n\nif( msg.topic == \"download\" || msg.topic == \"query\" ){\n    \n   \n\n    var sec_sens  = flow.get( \"secim\" )|| false ;  //  sensor choice\n    \n    var start_Date = flow.get( \"startDate\" ) || false ;\n    var start_Time = flow.get( \"bas_saat\" )  || false ;\n    \n    var end_Date = flow.get( \"endDate\" )  || false ;\n    var end_Time = flow.get(\"bitis_saat\") || false ;\n\n\n    // check if date range is correct\n    if ( start_Date && end_Date && ( new Date(end_Date) >= new Date(start_Date) ) ) \n    {\n        msg.topic = \"select * from  \" + sec_sens + \"   where Zaman between '\" + start_Date + \" \" + start_Time + \"' and '\" + end_Date +\" \" + end_Time + \"'\";\n        return msg;                                 /*  Exp:  Zaman = Time   */\n    } else {\n        node.warn(\"end date is before start date. or context not set\");\n    }\n\n    \n\n}\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":480,"wires":[["c18eb38d29190239"]]},{"id":"f014b99f92495f10","type":"ui_date_picker","z":"be4ba5fc5add8b7d","name":"","label":"Start Date","group":"2f70fd7d67ed6a37","order":1,"width":7,"height":1,"passthru":false,"topic":"payload","topicType":"msg","className":"","x":220,"y":440,"wires":[["199811dd92bf33db"]]},{"id":"199811dd92bf33db","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"startDate","pt":"flow","to":"$moment($$.payload).format(\"YYYY-MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":440,"wires":[["7b156ef5d6e1546b","61bc08b1b3802736"]]},{"id":"7c1a0501448b83e4","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"endDate","pt":"flow","to":"$moment($$.payload).format(\"YYYY-MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":540,"wires":[["7b156ef5d6e1546b","61bc08b1b3802736"]]},{"id":"e41c2bbba7726930","type":"ui_date_picker","z":"be4ba5fc5add8b7d","name":"","label":"End Date","group":"2f70fd7d67ed6a37","order":6,"width":7,"height":1,"passthru":false,"topic":"payload","topicType":"msg","className":"","x":220,"y":540,"wires":[["7c1a0501448b83e4"]]},{"id":"b9b35ffd865f76f8","type":"ui_dropdown","z":"be4ba5fc5add8b7d","name":"","label":"Sensor choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":3,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"1.Sensor","value":"sensor_1","type":"str"},{"label":"2.Sensor ","value":"sensor_2","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":240,"y":340,"wires":[["e297fe905c4929a0"]]},{"id":"e297fe905c4929a0","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"secim","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":340,"wires":[["7b156ef5d6e1546b"]]},{"id":"4415581852290f1f","type":"ui_dropdown","z":"be4ba5fc5add8b7d","name":"","label":"Temp / hum choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":8,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"Sicaklik","value":"Sicaklik","type":"str"},{"label":"Nem","value":"Nem","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":250,"y":280,"wires":[["81f45eea70528973"]]},{"id":"81f45eea70528973","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"secim1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":280,"wires":[["7b156ef5d6e1546b"]]},{"id":"c2f16d5d5d8843ce","type":"ui_dropdown","z":"be4ba5fc5add8b7d","name":"","label":"Temp / Hum  choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":9,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"Sicaklik","value":"Sicaklik","type":"str"},{"label":"Nem","value":"Nem","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":250,"y":140,"wires":[["0b13e600d79e6f17"]]},{"id":"b7e9e02e8f6fc68a","type":"ui_dropdown","z":"be4ba5fc5add8b7d","name":"","label":"Sensor choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":4,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"1.Sensor","value":"sensor_1","type":"str"},{"label":"2.Sensor","value":"sensor_2","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":240,"y":200,"wires":[["edd796751e8ed69b"]]},{"id":"0b13e600d79e6f17","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"k_secim2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":140,"wires":[["7b156ef5d6e1546b"]]},{"id":"edd796751e8ed69b","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"k_secim3","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":200,"wires":[["61bc08b1b3802736"]]},{"id":"6a057478727c289e","type":"debug","z":"be4ba5fc5add8b7d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1570,"y":480,"wires":[]},{"id":"b640fe2bd4c2d13a","type":"function","z":"be4ba5fc5add8b7d","name":"","func":"var sec_sens2 = flow.get( \"k_secim2\" ) || false ;\nvar sec_sens3 = flow.get( \"k_secim3\" ) || false;\n\n\nvar data1 = [];\nvar data = [];\nvar Zaman = [];\nvar Zaman1 = [];\nmsg.payload.forEach(function(value) {\n\n data1.push(value[sec_sens2] );  // temp or hum choice\n Zaman1.push(value[ 'Zaman' ] ); //  time data   /*  Exp:  Zaman = Time   */\n \n \n});\n\n\nmsg.payload = [{\n    \n series: [  \"\"+ sec_sens3 + \"   \"   + sec_sens2 +\" verisi\" ],\n data: [ data1 ],\n labels: Zaman1\n\n}];\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":720,"wires":[["57ec96c3bf52e191"]]},{"id":"61bc08b1b3802736","type":"function","z":"be4ba5fc5add8b7d","name":"sensor_2 get_data","func":"\n    if(msg.topic == \"query\") {\n        \n    var start_Date = flow.get( \"startDate\" ) || false;    \n    var end_Date   = flow.get( \"endDate\"   ) || false;\n    var start_Time = flow.get( \"bas_saat\"  ) || false;\n    var end_Time   = flow.get( \"bitis_saat\") || false;  \n    var sec_sens3  = flow.get( \"k_secim3\"  ) || false; // sensor choice\n\n\n\n    // check if date range is correct\n    if ( start_Date && end_Date && ( new Date(end_Date) >= new Date(start_Date) ) ) \n    {\n        msg.topic = \"select * from  \" + sec_sens3 + \"   where Zaman between '\" + start_Date + \" \" + start_Time + \"' and '\" + end_Date +\" \" + end_Time + \"'\";\n        return msg;                                 /*  Exp:  Zaman = Time   */\n    } else {\n        node.warn(\"end date is before start date. or context not set\"); \n        \n    \n        \n    }\n\n   }","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":720,"wires":[["55f25ef358350b28"]]},{"id":"55f25ef358350b28","type":"mysql","z":"be4ba5fc5add8b7d","mydb":"496de392.ca2cbc","name":"","x":1070,"y":720,"wires":[["b640fe2bd4c2d13a"]]},{"id":"57ec96c3bf52e191","type":"ui_chart","z":"be4ba5fc5add8b7d","name":"","group":"2f70fd7d67ed6a37","order":12,"width":30,"height":5,"label":"","chartType":"line","legend":"true","xformat":"Y-M-D / HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":true,"colors":["#fbff05","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1390,"y":720,"wires":[["c669254cf5a64276"]]},{"id":"b11dbde85f82f908","type":"ui_text_input","z":"be4ba5fc5add8b7d","name":"","label":"Start Hours","tooltip":"","group":"2f70fd7d67ed6a37","order":2,"width":6,"height":1,"passthru":true,"mode":"time","delay":"0","topic":"bas_saat","sendOnBlur":true,"className":"","topicType":"msg","x":230,"y":480,"wires":[["2ef44bf195d4c133"]]},{"id":"789f926592e6a2d7","type":"ui_text_input","z":"be4ba5fc5add8b7d","name":"","label":"End Hours","tooltip":"","group":"2f70fd7d67ed6a37","order":7,"width":6,"height":1,"passthru":true,"mode":"time","delay":"0","topic":"bitis_saat","sendOnBlur":true,"className":"","topicType":"msg","x":230,"y":600,"wires":[["333826dca1b5151d"]]},{"id":"2ef44bf195d4c133","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"bas_saat","pt":"flow","to":"$moment($$.payload).tz(\"UTC\").format(\"HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":480,"wires":[["7b156ef5d6e1546b","61bc08b1b3802736"]]},{"id":"333826dca1b5151d","type":"change","z":"be4ba5fc5add8b7d","name":"","rules":[{"t":"set","p":"bitis_saat","pt":"flow","to":"$moment($$.payload).tz(\"UTC\").format(\"HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":600,"wires":[["7b156ef5d6e1546b","61bc08b1b3802736"]]},{"id":"c669254cf5a64276","type":"debug","z":"be4ba5fc5add8b7d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1570,"y":720,"wires":[]},{"id":"496de392.ca2cbc","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"dnm","tz":"+3:00","charset":"UTF8"},{"id":"2f70fd7d67ed6a37","type":"ui_group","name":"Database veri çekme","tab":"22aa4264a26a4cce","order":1,"disp":true,"width":30,"collapse":false,"className":""},{"id":"22aa4264a26a4cce","type":"ui_tab","name":"Sensor 3","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

structure your query to return both sensors data in one query (instead of 2 separate queries) then adjust your function to build the necessary payload as is described in the built in help of the chart node.

Hi;
I configured my query to return both sensor data in a single query. But I could not make the necessary configuration in the "get data func" node. I tried to take the incoming data number and divide it by two and print it. It didn't work. How can I separate the get data func from sensor1 and sensor 2
thanks in advance

[{"id":"239b2679b6d09dd0","type":"tab","label":"Flow 17","disabled":false,"info":"","env":[]},{"id":"31fe7dc391652a26","type":"mysql","z":"239b2679b6d09dd0","mydb":"496de392.ca2cbc","name":"","x":1050,"y":220,"wires":[["072bc53ce15c9390"]]},{"id":"fce3b0d486214897","type":"ui_chart","z":"239b2679b6d09dd0","name":"","group":"2f70fd7d67ed6a37","order":11,"width":30,"height":5,"label":"","chartType":"line","legend":"true","xformat":"Y-M-D / HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":true,"colors":["#1f96ea","#0bf933","#f97d10","#2ca02c","#37f20d","#fb0909","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1370,"y":220,"wires":[["d15b14321195f9a6"]]},{"id":"072bc53ce15c9390","type":"function","z":"239b2679b6d09dd0","name":"","func":"var sec_sens1 = flow.get( \"secim1\" ) || false ;\nvar sec_sens  = flow.get( \"secim\"  ) || false ; \n\nvar data1 = [];\nvar data = [];\nvar Zaman = [];\nvar Zaman1 = [];\n\nmsg.payload.forEach(function(value) {\n    \n data.push( value[ sec_sens1 ] );  // temp or hum choice \n Zaman1.push( value['Zaman'] );   // time data   /*  Exp:  Zaman = Time   */\n \n});\n\n\nmsg.payload = [{\n    \n series: [ \"\"+ sec_sens + \"   \"   + sec_sens1 +\" verisi\"],\n data: [ data ],\n labels: Zaman1\n\n}];\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":220,"wires":[["fce3b0d486214897"]]},{"id":"06e286c98649296c","type":"ui_button","z":"239b2679b6d09dd0","name":"","group":"2f70fd7d67ed6a37","order":5,"width":3,"height":2,"passthru":false,"label":"Get","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"date","topic":"query","topicType":"str","x":430,"y":780,"wires":[["5fa9836a542c5a5a","6d95eda5b3de5507","f88b2ae34b5e8ba7"]]},{"id":"5fa9836a542c5a5a","type":"function","z":"239b2679b6d09dd0","name":"sensor_1 get_data","func":"\n\nif( msg.topic == \"download\" || msg.topic == \"query\" ){\n    \n   \n\n    var sec_sens  = flow.get( \"secim\" )|| false ;  //  sensor choice\n    \n    var start_Date = flow.get( \"startDate\" ) || false ;\n    var start_Time = flow.get( \"bas_saat\" )  || false ;\n    \n    var end_Date = flow.get( \"endDate\" )  || false ;\n    var end_Time = flow.get(\"bitis_saat\") || false ;\n\n\n    // check if date range is correct\n    if ( start_Date && end_Date && ( new Date(end_Date) >= new Date(start_Date) ) ) \n    {\n        msg.topic = \"select * from  \" + sec_sens + \"   where Zaman between '\" + start_Date + \" \" + start_Time + \"' and '\" + end_Date +\" \" + end_Time + \"'\";\n        return msg;                                 /*  Exp:  Zaman = Time   */\n    } else {\n        node.warn(\"end date is before start date. or context not set\");\n    }\n\n    \n\n}\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":220,"wires":[["31fe7dc391652a26"]]},{"id":"375c69f15e230ba9","type":"ui_date_picker","z":"239b2679b6d09dd0","name":"","label":"Start Date","group":"2f70fd7d67ed6a37","order":1,"width":7,"height":1,"passthru":false,"topic":"payload","topicType":"msg","className":"","x":120,"y":480,"wires":[["d808dfe778e437ac"]]},{"id":"d808dfe778e437ac","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"startDate","pt":"flow","to":"$moment($$.payload).format(\"YYYY-MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":480,"wires":[["5fa9836a542c5a5a","6d95eda5b3de5507","f88b2ae34b5e8ba7"]]},{"id":"29c89db54f86eeee","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"endDate","pt":"flow","to":"$moment($$.payload).format(\"YYYY-MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":580,"wires":[["5fa9836a542c5a5a","6d95eda5b3de5507","f88b2ae34b5e8ba7"]]},{"id":"e8439377e69c3156","type":"ui_date_picker","z":"239b2679b6d09dd0","name":"","label":"End Date","group":"2f70fd7d67ed6a37","order":6,"width":7,"height":1,"passthru":false,"topic":"payload","topicType":"msg","className":"","x":120,"y":580,"wires":[["29c89db54f86eeee"]]},{"id":"c8a93095c273ad25","type":"ui_dropdown","z":"239b2679b6d09dd0","name":"","label":"Sensor choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":3,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"1.Sensor","value":"sensor_1","type":"str"},{"label":"2.Sensor ","value":"sensor_2","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":140,"y":380,"wires":[["cec79928fbf7eede"]]},{"id":"cec79928fbf7eede","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"secim","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":380,"wires":[["5fa9836a542c5a5a","f88b2ae34b5e8ba7"]]},{"id":"3fc3a5f29885a835","type":"ui_dropdown","z":"239b2679b6d09dd0","name":"","label":"Temp / hum choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":8,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"Sicaklik","value":"Sicaklik","type":"str"},{"label":"Nem","value":"Nem","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":150,"y":320,"wires":[["f8b437d1fd8d6cc7"]]},{"id":"f8b437d1fd8d6cc7","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"secim1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":320,"wires":[["5fa9836a542c5a5a","f88b2ae34b5e8ba7"]]},{"id":"e62aa4822932be86","type":"ui_dropdown","z":"239b2679b6d09dd0","name":"","label":"Temp / Hum  choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":9,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"Sicaklik","value":"Sicaklik","type":"str"},{"label":"Nem","value":"Nem","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":150,"y":180,"wires":[["9951b7e373af083c"]]},{"id":"926e25f237556260","type":"ui_dropdown","z":"239b2679b6d09dd0","name":"","label":"Sensor choice","tooltip":"","place":"Select option","group":"2f70fd7d67ed6a37","order":4,"width":7,"height":1,"passthru":true,"multiple":false,"options":[{"label":"1.Sensor","value":"sensor_1","type":"str"},{"label":"2.Sensor","value":"sensor_2","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":140,"y":240,"wires":[["fd9b3e0f987c07a2"]]},{"id":"9951b7e373af083c","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"k_secim2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":180,"wires":[["5fa9836a542c5a5a","f88b2ae34b5e8ba7"]]},{"id":"fd9b3e0f987c07a2","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"k_secim3","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":240,"wires":[["6d95eda5b3de5507","f88b2ae34b5e8ba7"]]},{"id":"d15b14321195f9a6","type":"debug","z":"239b2679b6d09dd0","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1550,"y":220,"wires":[]},{"id":"4d137e6f39727de7","type":"function","z":"239b2679b6d09dd0","name":"","func":"var sec_sens2 = flow.get( \"k_secim2\" ) || false ;\nvar sec_sens3 = flow.get( \"k_secim3\" ) || false;\n\n\nvar data1 = [];\nvar data = [];\nvar Zaman = [];\nvar Zaman1 = [];\nmsg.payload.forEach(function(value) {\n\n data1.push(value[sec_sens2] );  // temp or hum choice\n Zaman1.push(value[ 'Zaman' ] ); //  time data   /*  Exp:  Zaman = Time   */\n \n \n});\n\n\nmsg.payload = [{\n    \n series: [  \"\"+ sec_sens3 + \"   \"   + sec_sens2 +\" verisi\" ],\n data: [ data1 ],\n labels: Zaman1\n\n}];\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":660,"wires":[["9d9d8c82fc50244c"]]},{"id":"6d95eda5b3de5507","type":"function","z":"239b2679b6d09dd0","name":"sensor_2 get_data","func":"\n    if(msg.topic == \"query\") {\n        \n    var start_Date = flow.get( \"startDate\" ) || false;    \n    var end_Date   = flow.get( \"endDate\"   ) || false;\n    var start_Time = flow.get( \"bas_saat\"  ) || false;\n    var end_Time   = flow.get( \"bitis_saat\") || false;  \n    var sec_sens3  = flow.get( \"k_secim3\"  ) || false; // sensor choice\n\n\n\n    // check if date range is correct\n    if ( start_Date && end_Date && ( new Date(end_Date) >= new Date(start_Date) ) ) \n    {\n        msg.topic = \"select * from  \" + sec_sens3 + \"   where Zaman between '\" + start_Date + \" \" + start_Time + \"' and '\" + end_Date +\" \" + end_Time + \"'\";\n        return msg;                                 /*  Exp:  Zaman = Time   */\n    } else {\n        node.warn(\"end date is before start date. or context not set\"); \n        \n    \n        \n    }\n\n   }","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":660,"wires":[["5ac2843586e12d69"]]},{"id":"5ac2843586e12d69","type":"mysql","z":"239b2679b6d09dd0","mydb":"496de392.ca2cbc","name":"","x":1050,"y":660,"wires":[["4d137e6f39727de7"]]},{"id":"9d9d8c82fc50244c","type":"ui_chart","z":"239b2679b6d09dd0","name":"","group":"2f70fd7d67ed6a37","order":12,"width":30,"height":5,"label":"","chartType":"line","legend":"true","xformat":"Y-M-D / HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":true,"colors":["#fbff05","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1370,"y":660,"wires":[["e006505708ed1b9c"]]},{"id":"d7de63e8881cd031","type":"ui_text_input","z":"239b2679b6d09dd0","name":"","label":"Start Hours","tooltip":"","group":"2f70fd7d67ed6a37","order":2,"width":6,"height":1,"passthru":true,"mode":"time","delay":"0","topic":"bas_saat","sendOnBlur":true,"className":"","topicType":"msg","x":130,"y":520,"wires":[["18b756f20cb5ac4b"]]},{"id":"164b59fbb158c143","type":"ui_text_input","z":"239b2679b6d09dd0","name":"","label":"End Hours","tooltip":"","group":"2f70fd7d67ed6a37","order":7,"width":6,"height":1,"passthru":true,"mode":"time","delay":"0","topic":"bitis_saat","sendOnBlur":true,"className":"","topicType":"msg","x":130,"y":640,"wires":[["827b5c7bedcb462a"]]},{"id":"18b756f20cb5ac4b","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"bas_saat","pt":"flow","to":"$moment($$.payload).tz(\"UTC\").format(\"HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":520,"wires":[["5fa9836a542c5a5a","6d95eda5b3de5507","f88b2ae34b5e8ba7"]]},{"id":"827b5c7bedcb462a","type":"change","z":"239b2679b6d09dd0","name":"","rules":[{"t":"set","p":"bitis_saat","pt":"flow","to":"$moment($$.payload).tz(\"UTC\").format(\"HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":640,"wires":[["5fa9836a542c5a5a","6d95eda5b3de5507","f88b2ae34b5e8ba7"]]},{"id":"e006505708ed1b9c","type":"debug","z":"239b2679b6d09dd0","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1550,"y":660,"wires":[]},{"id":"939f67e22e0fefa4","type":"function","z":"239b2679b6d09dd0","name":"get data func.","func":"var sec_sens1 = flow.get( \"secim1\" ) || false ;\nvar sec_sens2 = flow.get( \"k_secim2\" ) || false ;\n\n//var sec_sens3 = flow.get( \"k_secim3\" ) || false;\n//var sec_sens  = flow.get( \"secim\"  ) || false ;\n  var i=0;\n  var veri = msg.payload.length;\n\nvar data1  = [];\nvar data   = [];\nvar Zaman  = [];\nvar Zaman1 = [];\n\n\nmsg.payload.forEach(function(value) {\n  if( i < ( (veri-3) / 2 ) ) {\n  i++;\n    data.push( value[ sec_sens1 ] );  // temp or hum choice\n    Zaman1.push( value['Zaman'] );   // time data    /*  Exp:  Zaman = Time   */\n}\n\n\n  else {\n  i++;\n    data1.push( value[ sec_sens2 ] );  // temp or hum choice\n    Zaman1.push( value['Zaman'] );   // time data    /*  Exp:  Zaman = Time   */\n  }  \n    \n \n \n \n \n   \n \n// Zaman.push( value['Zaman'] );   // time data   /*  Exp:  Zaman = Time   */\n//Zaman1.push( value['Zaman'] );   // time data    /*  Exp:  Zaman = Time   */\n \n});\n\n\nmsg.payload = [{\n    \n series: [ \" 1.Sensor \" , \" 2.Sensor \"] ,\n data:   [ data , data1 ] ,\n labels: Zaman1\n\n}];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1180,"y":420,"wires":[["7e24657569500c3e"]]},{"id":"7e24657569500c3e","type":"ui_chart","z":"239b2679b6d09dd0","name":"","group":"2f70fd7d67ed6a37","order":13,"width":"30","height":"5","label":"data comparison","chartType":"line","legend":"false","xformat":"Y-M-D / HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":true,"colors":["#1f77b4","#fff714","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1400,"y":420,"wires":[["47c0ed0fcafb6a52"]]},{"id":"7a8b22742f04ccde","type":"mysql","z":"239b2679b6d09dd0","mydb":"496de392.ca2cbc","name":"","x":1010,"y":420,"wires":[["939f67e22e0fefa4"]]},{"id":"f88b2ae34b5e8ba7","type":"function","z":"239b2679b6d09dd0","name":"","func":"\n\nif( msg.topic == \"download\" || msg.topic == \"query\" ){\n    \n   \n\n    var sec_sens  = flow.get( \"secim\" )|| false ;  //  sensor choice\n    var sec_sens3 = flow.get( \"k_secim3\"  ) || false ; // sensor choice\n    \n    var sec_sens1 = flow.get( \"secim1\" ) || false ; // temp or hum  1. sens\n    var sec_sens2 = flow.get( \"k_secim2\" ) || false ; // temp or hum 2.sens\n    \n    \n    \n    var start_Date = flow.get( \"startDate\" ) || false ;\n    var start_Time = flow.get( \"bas_saat\" )  || false ;\n    \n    var end_Date = flow.get( \"endDate\" )  || false ;\n    var end_Time = flow.get( \"bitis_saat\" ) || false ;\n\n\n    // check if date range is correct\n    if ( start_Date && end_Date && ( new Date(end_Date) >= new Date(start_Date) ) ) \n    {\n        msg.topic = \"SELECT d1.\"+sec_sens1+\", d1.Zaman FROM \"+sec_sens+\" d1 WHERE Zaman BETWEEN '\" + start_Date + \" \" + start_Time + \"' and '\" + end_Date +\" \" + end_Time + \"'  UNION SELECT d2.\"+sec_sens2+\", d2.Zaman FROM \"+sec_sens3+\" d2 WHERE Zaman BETWEEN '\" + start_Date + \" \" + start_Time + \"' and '\" + end_Date +\" \" + end_Time + \"'\";\n                   \n                   \n                     \n\n/*        \n        SELECT d1.Nem, d1.Sicaklik, d1.Zaman\n        FROM sensor_1 d1 WHERE Zaman BETWEEN\n            '2022-08-26' and '2022-08-27'\n            UNION  \n            SELECT d2.Nem, d2.Sicaklik, d2.Zaman  \n          FROM sensor_2 d2 WHERE Zaman BETWEEN\n           '2022-08-26' and '2022-08-27';\n*/        \n        \n        \n  /*      \"select \"+sec_sens+\".\"+sec_sens1+\",\"+sec_sens3+\".\"+sec_sens2+\" from \"+sec_sens+\" , \"+sec_sens3+\" where sensor_2.Zaman between '\"+start_Date+\" \"+start_Time+\"' and '\"+end_Date+\" \"+end_Time+\"'\";   */\n        \n  /*      \"select * from  \" + sec_sens + \"   where Zaman between '\" + start_Date + \" \" + start_Time + \"' and '\" + end_Date +\" \" + end_Time + \"'\";   */\n\n\n\n\n        return msg;                                 /*  Exp:  Zaman = Time   */\n    } else {\n        node.warn(\"end date is before start date. or context not set\");\n    }\n\n    \n\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":420,"wires":[["7a8b22742f04ccde"]]},{"id":"47c0ed0fcafb6a52","type":"debug","z":"239b2679b6d09dd0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1590,"y":420,"wires":[]},{"id":"496de392.ca2cbc","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"dnm","tz":"+3:00","charset":"UTF8"},{"id":"2f70fd7d67ed6a37","type":"ui_group","name":"Database veri çekme","tab":"22aa4264a26a4cce","order":1,"disp":true,"width":30,"collapse":false,"className":""},{"id":"22aa4264a26a4cce","type":"ui_tab","name":"Sensor 3","icon":"dashboard","order":3,"disabled":false,"hidden":false}]


Don't know if this helps but I worked on something similar today for myself - I log power consumption from a number of plugs into a database, and wanted to graph the monthly consumption for each plug.

The query I wrote returns
PlugId eg Lamp, Computer etc
Total ie kWh used
Monthname the month name in which the appliance consumed the power

in the order in which I want to use them.

So I wrote the following.

Perhaps that helps you?

/*
Target data format

[{
    "series": ["X", "Y", "Z"],
    "data": [[5, 6, 9, 10], [3, 8, 5, 10], [6, 7, 2, 10]],
    "labels": ["Jan", "Feb", "Mar", "Apr"]
}]
*/

var PlugId = [];
var Total = [];
var Monthname = [];
var Data = [];


msg.payload.forEach(function (value) {
    if (PlugId.indexOf(value['PlugId']) === -1){
        PlugId.push(value['PlugId']);
        Data[PlugId.indexOf(value['PlugId'])]  = [];
    }
    if (Monthname.indexOf(value['Monthname']) === -1) {
        Monthname.push(value['Monthname']);
    }
    Data[PlugId.indexOf(value['PlugId'])].push(value['Total']);
});



msg.payload = [{
    series: PlugId,
    data: Data,
    labels: Monthname
}];
return msg;