# Display hourly production in bar graph

**URL:** <https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591>\
**Category:** General\
**Created:** [3 April 2021 09:31 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591 "2021-04-03T09:31:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [3 April 2021 09:31 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/1 "2021-04-03T09:31:52Z")

</div>

Hello! I Need to display hourly production (24 hr) on a bar chart, below given is the flow I've created :

- sharing only half of the flow due to character limitation of 32000.

```auto
[{"id":"887bdbcf.967d28","type":"function","z":"dc05cb71.fd2b78","name":"1st hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='firsthr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":733,"wires":[["738030fe.57821","45a6ea17.598df4","c3070d88.15fb3"]]},{"id":"738030fe.57821","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1347,"y":728,"wires":[]},{"id":"33015992.c29d26","type":"function","z":"dc05cb71.fd2b78","name":"2nd hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='secondhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":800,"wires":[["45a6ea17.598df4","182bd831.129488"]]},{"id":"45a6ea17.598df4","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":801,"wires":[["76e8eb36.54d2d4","176775f3.047daa"]]},{"id":"76e8eb36.54d2d4","type":"function","z":"dc05cb71.fd2b78","name":"2nd hr - 1st hr","func":"msg.payload = (msg.payload.secondhr - msg.payload.firsthr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":781,"wires":[["72a8a588.bca9bc","2d6b6334.a2101c"]]},{"id":"176775f3.047daa","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":821,"wires":[]},{"id":"f5ff1fef.f3026","type":"function","z":"dc05cb71.fd2b78","name":"3rd hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='thirdhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":872,"wires":[["182bd831.129488","bba8e527.573368"]]},{"id":"182bd831.129488","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":873,"wires":[["13334bbc.8e7194","3fbd997.1515166"]]},{"id":"13334bbc.8e7194","type":"function","z":"dc05cb71.fd2b78","name":"3rd hr - 2nd hr","func":"msg.payload = (msg.payload.thirdhr - msg.payload.secondhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":873,"wires":[["76c66b57.1c1434","9e505d5b.a56dc"]]},{"id":"3fbd997.1515166","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":913,"wires":[]},{"id":"b338ed3f.f464b","type":"function","z":"dc05cb71.fd2b78","name":"4th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='fourthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":965,"wires":[["bba8e527.573368","10e9c8ec.3fa287"]]},{"id":"bba8e527.573368","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":966,"wires":[["f1b9c397.a0f41","584ea7cc.1e3b68"]]},{"id":"f1b9c397.a0f41","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1006,"wires":[]},{"id":"5c1b808c.345ca","type":"function","z":"dc05cb71.fd2b78","name":"5th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='fifthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1056,"wires":[["10e9c8ec.3fa287","c39e8fec.7f71"]]},{"id":"10e9c8ec.3fa287","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1057,"wires":[["4165f1ef.54d43","eca4c2cb.bb234"]]},{"id":"791226a1.ca7ab8","type":"function","z":"dc05cb71.fd2b78","name":"6th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='sixthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1143,"wires":[["c39e8fec.7f71","42b7460.243fabc"]]},{"id":"c39e8fec.7f71","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1144,"wires":[["9ec4fe6f.09617","e293e188.4a832"]]},{"id":"1ce80728.9b0e49","type":"function","z":"dc05cb71.fd2b78","name":"7th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='seventhhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1233,"wires":[["42b7460.243fabc","a3fdc32d.f0014"]]},{"id":"42b7460.243fabc","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1234,"wires":[["f3646ffa.b332c","8d0b7577.05ca88"]]},{"id":"e3090067.e5174","type":"function","z":"dc05cb71.fd2b78","name":"8th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='eighthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1322,"wires":[["a3fdc32d.f0014","f260153.16ce3e8"]]},{"id":"a3fdc32d.f0014","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1323,"wires":[["94e6632.6a729a","545f9c39.528d94"]]},{"id":"59531859.ce3c98","type":"function","z":"dc05cb71.fd2b78","name":"9th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='ninthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1410,"wires":[["f260153.16ce3e8","ad4d9ab7.e91208"]]},{"id":"f260153.16ce3e8","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1411,"wires":[["ef8b642b.529678","d9fecc75.f0494"]]},{"id":"6f8bbee.6bec64","type":"function","z":"dc05cb71.fd2b78","name":"10th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='tenthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":780,"y":1499,"wires":[["ad4d9ab7.e91208","135b9052.fceac"]]},{"id":"ad4d9ab7.e91208","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1500,"wires":[["5139fd70.a7de54","df08c9b8.a097d8"]]},{"id":"fbf9eb4d.985b88","type":"function","z":"dc05cb71.fd2b78","name":"11th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='eleventhhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1589,"wires":[["135b9052.fceac","484a9f2f.f019"]]},{"id":"135b9052.fceac","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1590,"wires":[["33f8271b.61c9f8","3fde8077.ac2f9"]]},{"id":"9f22729c.087ac","type":"function","z":"dc05cb71.fd2b78","name":"12th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='twelfthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":780,"y":1678,"wires":[["484a9f2f.f019","1e0becf8.c37a63"]]},{"id":"484a9f2f.f019","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1679,"wires":[["2cf8449d.4666bc","b97d23ab.a8824"]]},{"id":"ade1634b.10b6","type":"function","z":"dc05cb71.fd2b78","name":"13th hr","func":"msg.payload = Number(msg.payload);\nmsg.topic='thirteenthhr';\nA = msg.payload;\nB = Math.pow(A,2);\nmsg.payload = Math.pow(B,0.5);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":780,"y":1767,"wires":[["1e0becf8.c37a63","825ac270.f1af7"]]},{"id":"1e0becf8.c37a63","type":"join","z":"dc05cb71.fd2b78","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1768,"wires":[["a6eaa974.2ea048","6640fe5d.70e0e"]]},{"id":"4165f1ef.54d43","type":"function","z":"dc05cb71.fd2b78","name":"5th hr - 4th hr","func":"msg.payload = (msg.payload.fifthhr - msg.payload.fourthhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1057,"wires":[["affcab5d.fb7418","f51ddfb0.e5bf1"]]},{"id":"584ea7cc.1e3b68","type":"function","z":"dc05cb71.fd2b78","name":"4th hr - 3rd hr","func":"msg.payload = (msg.payload.fourthhr - msg.payload.thirdhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":966,"wires":[["77ef78e7.8b78a8","b320fa00.841aa8"]]},{"id":"9ec4fe6f.09617","type":"function","z":"dc05cb71.fd2b78","name":"6th hr - 5th hr","func":"msg.payload = (msg.payload.sixthhr - msg.payload.fifthhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1144,"wires":[["8b8240a7.987c3","474e2a03.9f0af4"]]},{"id":"eca4c2cb.bb234","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1097,"wires":[]},{"id":"e293e188.4a832","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1184,"wires":[]},{"id":"f3646ffa.b332c","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1274,"wires":[]},{"id":"94e6632.6a729a","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1363,"wires":[]},{"id":"ef8b642b.529678","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1451,"wires":[]},{"id":"5139fd70.a7de54","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1540,"wires":[]},{"id":"33f8271b.61c9f8","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1630,"wires":[]},{"id":"2cf8449d.4666bc","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1719,"wires":[]},{"id":"a6eaa974.2ea048","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":1808,"wires":[]},{"id":"8d0b7577.05ca88","type":"function","z":"dc05cb71.fd2b78","name":"7th hr - 6th hr","func":"msg.payload = (msg.payload.seventhhr - msg.payload.sixthhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1234,"wires":[["926acf6c.96024","673089ab.5f19b8"]]},{"id":"545f9c39.528d94","type":"function","z":"dc05cb71.fd2b78","name":"8th hr - 7th hr","func":"msg.payload = (msg.payload.eighthhr - msg.payload.seventhhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1323,"wires":[["c29c15b7.269138","73ae88a8.2cc7c8"]]},{"id":"d9fecc75.f0494","type":"function","z":"dc05cb71.fd2b78","name":"9th hr - 8th hr","func":"msg.payload = (msg.payload.ninthhr - msg.payload.eighthhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1411,"wires":[["73f4f446.9018ac","e45353e1.b65e2"]]},{"id":"df08c9b8.a097d8","type":"function","z":"dc05cb71.fd2b78","name":"10th hr - 9th hr","func":"msg.payload = (msg.payload.tenthhr - msg.payload.ninthhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1500,"wires":[["6da9e1ba.1507e","1edef913.27f427"]]},{"id":"3fde8077.ac2f9","type":"function","z":"dc05cb71.fd2b78","name":"11th hr - 10th hr","func":"msg.payload = (msg.payload.eleventhhr - msg.payload.tenthhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1590,"wires":[["37ab4a54.b4f5e6","74b0151d.06d53c"]]},{"id":"b97d23ab.a8824","type":"function","z":"dc05cb71.fd2b78","name":"12th hr - 11th hr","func":"msg.payload = (msg.payload.twelfthhr - msg.payload.eleventhhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1679,"wires":[["68881e65.aca8e","b88239a6.213ec8"]]},{"id":"6640fe5d.70e0e","type":"function","z":"dc05cb71.fd2b78","name":"13th hr - 12th hr","func":"msg.payload = (msg.payload.thirteenthhr - msg.payload.twelfthhr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":1768,"wires":[["c627df32.43213","d2624c3c.cdab1"]]},{"id":"db8fc03d.8434e","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["1d762f01.992631","87c11fb5.11495","759bf909.560238"],"x":655,"y":740,"wires":[["887bdbcf.967d28"]]},{"id":"c5ea194e.63a078","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["1d762f01.992631"],"x":655,"y":800,"wires":[["33015992.c29d26"]]},{"id":"21ad2e80.7042e2","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["1d762f01.992631"],"x":655,"y":872,"wires":[["f5ff1fef.f3026"]]},{"id":"62791b0d.1a4304","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["1d762f01.992631"],"x":655,"y":965,"wires":[["b338ed3f.f464b"]]},{"id":"903bb1a8.4f0e9","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["1d762f01.992631"],"x":655,"y":1056,"wires":[["5c1b808c.345ca"]]},{"id":"7f91751c.27bbec","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["1d762f01.992631"],"x":655,"y":1143,"wires":[["791226a1.ca7ab8"]]},{"id":"142cc3f7.f8b43c","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["1d762f01.992631"],"x":655,"y":1233,"wires":[["1ce80728.9b0e49"]]},{"id":"390840a6.327ee","type":"link in","z":"dc05cb71.fd2b78","name":"","links":[],"x":655,"y":1322,"wires":[["e3090067.e5174"]]},{"id":"84561d53.60bb1","type":"link in","z":"dc05cb71.fd2b78","name":"","links":[],"x":655,"y":1410,"wires":[["59531859.ce3c98"]]},{"id":"60a895bc.8c84ec","type":"link in","z":"dc05cb71.fd2b78","name":"","links":[],"x":655,"y":1499,"wires":[["6f8bbee.6bec64"]]},{"id":"1cfad5f0.eb641a","type":"link in","z":"dc05cb71.fd2b78","name":"","links":[],"x":655,"y":1589,"wires":[["fbf9eb4d.985b88"]]},{"id":"732e441f.8546ac","type":"link in","z":"dc05cb71.fd2b78","name":"","links":[],"x":655,"y":1678,"wires":[["9f22729c.087ac"]]},{"id":"adbc7d85.23fab","type":"link in","z":"dc05cb71.fd2b78","name":"","links":[],"x":655,"y":1767,"wires":[["ade1634b.10b6"]]},{"id":"72a8a588.bca9bc","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":781,"wires":[]},{"id":"76c66b57.1c1434","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":873,"wires":[]},{"id":"77ef78e7.8b78a8","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":966,"wires":[]},{"id":"affcab5d.fb7418","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1057,"wires":[]},{"id":"8b8240a7.987c3","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1144,"wires":[]},{"id":"926acf6c.96024","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1234,"wires":[]},{"id":"c29c15b7.269138","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1323,"wires":[]},{"id":"73f4f446.9018ac","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1411,"wires":[]},{"id":"6da9e1ba.1507e","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1500,"wires":[]},{"id":"37ab4a54.b4f5e6","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1590,"wires":[]},{"id":"68881e65.aca8e","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1679,"wires":[]},{"id":"c627df32.43213","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":1768,"wires":[]},{"id":"763f517a.259b","type":"link in","z":"dc05cb71.fd2b78","name":"","links":["72a8a588.bca9bc","76c66b57.1c1434","77ef78e7.8b78a8","affcab5d.fb7418","8b8240a7.987c3","926acf6c.96024","c29c15b7.269138","73f4f446.9018ac","6da9e1ba.1507e","37ab4a54.b4f5e6","68881e65.aca8e","c627df32.43213","68ac5d8c.9eeb14","26500912.9169d6","cfc21f02.ad17b","406e6b54.b7a504","a8ca7e4f.23d13","29db3383.d4ca8c","595467b1.318188","4467006a.8c711","f7bedbd5.23a628","c388dce0.df343","bb6f6d1e.f7709","c3070d88.15fb3"],"x":1555,"y":1020,"wires":[["7b68c736.103a08"]]},{"id":"9c3b0f68.ac981","type":"influxdb in","z":"dc05cb71.fd2b78","influxdb":"ed827551.b18638","name":"","query":"SELECT * FROM \"hourlyprod\".\"autogen\".\"hourlyprod M02CN001\" WHERE time > now() -24h","rawOutput":false,"precision":"","retentionPolicy":"","org":"my-org","x":1820,"y":880,"wires":[["fb8710ef.94d52","b7a37ee4.e9747","8a1aef3f.986ad"]]},{"id":"7b68c736.103a08","type":"influxdb out","z":"dc05cb71.fd2b78","influxdb":"366c49bb.664296","name":"M02CN001","measurement":"hourlyprod M02CN001","precision":"","retentionPolicy":"","database":"hourlyprod","precisionV18FluxV20":"s","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1710,"y":1020,"wires":[]},{"id":"2d6b6334.a2101c","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":820,"wires":[]},{"id":"9e505d5b.a56dc","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":909,"wires":[]},{"id":"b320fa00.841aa8","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1000,"wires":[]},{"id":"f51ddfb0.e5bf1","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1093,"wires":[]},{"id":"474e2a03.9f0af4","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1180,"wires":[]},{"id":"673089ab.5f19b8","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1269,"wires":[]},{"id":"73ae88a8.2cc7c8","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1357,"wires":[]},{"id":"e45353e1.b65e2","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1445,"wires":[]},{"id":"1edef913.27f427","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1540,"wires":[]},{"id":"74b0151d.06d53c","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1622,"wires":[]},{"id":"b88239a6.213ec8","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1709,"wires":[]},{"id":"d2624c3c.cdab1","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1350,"y":1801,"wires":[]},{"id":"c3070d88.15fb3","type":"link out","z":"dc05cb71.fd2b78","name":"","links":["763f517a.259b"],"x":1295,"y":691,"wires":[]},{"id":"d50b8915.e09d68","type":"inject","z":"dc05cb71.fd2b78","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1640,"y":880,"wires":[["9c3b0f68.ac981"]]},{"id":"b7a37ee4.e9747","type":"ui_chart","z":"dc05cb71.fd2b78","name":"","group":"b0f97496.a4d498","order":9,"width":"24","height":"4","label":"A","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"1","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":2030,"y":860,"wires":[[]]},{"id":"fb8710ef.94d52","type":"debug","z":"dc05cb71.fd2b78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2050,"y":900,"wires":[]},{"id":"8a1aef3f.986ad","type":"ui_table","z":"dc05cb71.fd2b78","group":"b0f97496.a4d498","name":"","order":11,"width":"9","height":"4","columns":[],"outputs":0,"cts":false,"x":2030,"y":960,"wires":[]},{"id":"ed827551.b18638","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"OEE","name":"1.x","usetls":false,"tls":"d50d0c9f.31e858","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true},{"id":"366c49bb.664296","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"temp","name":"Influx","usetls":false,"tls":"","influxdbVersion":"1.8-flux","url":"http://localhost:8086/","rejectUnauthorized":false},{"id":"b0f97496.a4d498","type":"ui_group","name":"testing","tab":"152250d2.cae22f","order":1,"disp":true,"width":24,"collapse":false},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false},{"id":"152250d2.cae22f","type":"ui_tab","name":"Testing","icon":"dashboard","order":14,"disabled":false,"hidden":false}]

```

Can anyone help me on this

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 April 2021 09:45 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/2 "2021-04-03T09:45:22Z")

</div>

> [@sahsha](#):
>
> Can anyone help me on this

Hi

Firstly, most of what you posted is completely irrelevant in helping you as the data comes from influx...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/023fb9000e19618c015044d0cce8ea1d5ab1e345.png)

In order to actually help, you need to show us the content of your data and provide a sample by clicking the "Copy Value" button when hovering over the data.

E.g...  
 ![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

  

If you want to solve this yourself, read the built in help

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/6/560bc16785731ff483451c713acfdb02023db0b2.png)

---

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [3 April 2021 09:53 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/3 "2021-04-03T09:53:24Z")

</div>

@Steve-Mcl , sharing the copied value

* * *

![screenshot3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb4ccf73095c36995283465c3a6aeb85f16d8f36.png)

* * *

```auto
[{"time":"2021-04-03T09:35:32.000Z","value":3},{"time":"2021-04-03T09:35:37.000Z","value":5},{"time":"2021-04-03T09:35:38.000Z","value":2},{"time":"2021-04-03T09:35:39.000Z","value":2},{"time":"2021-04-03T09:35:57.000Z","value":10},{"time":"2021-04-03T09:35:58.000Z","value":10},{"time":"2021-04-03T09:35:59.000Z","value":7},{"time":"2021-04-03T09:36:00.000Z","value":7},{"time":"2021-04-03T09:36:01.000Z","value":6},{"time":"2021-04-03T09:36:02.000Z","value":7},{"time":"2021-04-03T09:36:03.000Z","value":15},{"time":"2021-04-03T09:36:04.000Z","value":12},{"time":"2021-04-03T09:36:05.000Z","value":9},{"time":"2021-04-03T09:36:06.000Z","value":10},{"time":"2021-04-03T09:36:07.000Z","value":9},{"time":"2021-04-03T09:36:08.000Z","value":8},{"time":"2021-04-03T09:36:09.000Z","value":8},{"time":"2021-04-03T09:36:10.000Z","value":11},{"time":"2021-04-03T09:36:11.000Z","value":11},{"time":"2021-04-03T09:36:12.000Z","value":7},{"time":"2021-04-03T09:36:13.000Z","value":7},{"time":"2021-04-03T09:36:14.000Z","value":15},{"time":"2021-04-03T09:36:15.000Z","value":8},{"time":"2021-04-03T09:36:16.000Z","value":8}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 April 2021 09:58 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/4 "2021-04-03T09:58:47Z")

</div>

From the docs, you need that data to look like this....

> for bars of the same colour, set the flag `Use first colour for all bars` in the node configuration, and set labels for each column
> 
> ```auto
> [{
> "series": ["X"],
> "data": [[5,6,9] ],
> "labels": ["Jan", "Feb", "Mar"]
> }]
> 
> ```

As you can see, your data in an `[array]` of `{objects}` with each containing 2 properties `time` and `value`.

So do you want me to do this for you (you wont really learn much) or are you going to give it a go yourself (and learn lots)?

---

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [3 April 2021 10:09 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/5 "2021-04-03T10:09:18Z")

</div>

@Steve-Mcl , your help will be appreciated 🙂. I've been struggling to get results for some days now 😐. Being a mechanical engineer I'm an infant 🍼 👶 who just stepped in coding.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 April 2021 10:15 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/6 "2021-04-03T10:15:50Z")

</div>

OK, well you will miss out on solving the puzzle, but here goes.

We need to convert

```auto
///current format...
[{"time":"2021-04-03T09:35:32.000Z","value":3}]

```

to

```auto
[{
    "series": ["X"],
    "data": [[5,6,9] ],
    "labels": ["Jan", "Feb", "Mar"]
}]

```

If we loop each row and take the time and add it to an array called `labels` and take the value and add that to another array called `data` we are half way there. The last piece of the puzzle is to put them into the required format.

function node (deliberately verbose and long hand to be as clear as possible)...

```auto
/* required format...
[{
    "series": ["X"],
    "data": [[5,6,9] ],
    "labels": ["Jan", "Feb", "Mar"]
}]
*/

/* current format...
[{"time":"2021-04-03T09:35:32.000Z","value":3}]
*/

var influxData = msg.payload; //for easy access to data & to clarify what we are working with.
msg.influxData = influxData; //keep a copy for reference (see debug output)

var data = []; //an array for bar chart data values
var labels = []; //an array for bar chart label values
for (let index = 0; index < influxData.length; index++) {
    const element = influxData[index]; //get this row of data
    const datetime = new Date(element.time); //get the time as a datetime object
    
    //get HH:mm and push it into the labels
    const time = datetime.getHours() + ":" + datetime.getMinutes();
    labels.push(time);

    //push value into the data
    const value = element.value;
    data.push(value);
}

//set payload to the correct bar chart format...
msg.payload = [{
    "series": ["X"],
    "data": [data],
    "labels": labels
}]

return msg;

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/4/841f1019f14c50a77a8b9d234e5c28fd71613399.png)

**NOTE** ↑ I dont think your data is _really_ "hourly" data (I'll leave that for your to sort out)

the demo flow...

```auto
[{"id":"7a91d5d2.0b8dbc","type":"inject","z":"83a23089.dc697","name":"demo influx data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"time\":\"2021-04-03T09:35:32.000Z\",\"value\":3},{\"time\":\"2021-04-03T09:35:37.000Z\",\"value\":5},{\"time\":\"2021-04-03T09:35:38.000Z\",\"value\":2},{\"time\":\"2021-04-03T09:35:39.000Z\",\"value\":2},{\"time\":\"2021-04-03T09:35:57.000Z\",\"value\":10},{\"time\":\"2021-04-03T09:35:58.000Z\",\"value\":10},{\"time\":\"2021-04-03T09:35:59.000Z\",\"value\":7},{\"time\":\"2021-04-03T09:36:00.000Z\",\"value\":7},{\"time\":\"2021-04-03T09:36:01.000Z\",\"value\":6},{\"time\":\"2021-04-03T09:36:02.000Z\",\"value\":7},{\"time\":\"2021-04-03T09:36:03.000Z\",\"value\":15},{\"time\":\"2021-04-03T09:36:04.000Z\",\"value\":12},{\"time\":\"2021-04-03T09:36:05.000Z\",\"value\":9},{\"time\":\"2021-04-03T09:36:06.000Z\",\"value\":10},{\"time\":\"2021-04-03T09:36:07.000Z\",\"value\":9},{\"time\":\"2021-04-03T09:36:08.000Z\",\"value\":8},{\"time\":\"2021-04-03T09:36:09.000Z\",\"value\":8},{\"time\":\"2021-04-03T09:36:10.000Z\",\"value\":11},{\"time\":\"2021-04-03T09:36:11.000Z\",\"value\":11},{\"time\":\"2021-04-03T09:36:12.000Z\",\"value\":7},{\"time\":\"2021-04-03T09:36:13.000Z\",\"value\":7},{\"time\":\"2021-04-03T09:36:14.000Z\",\"value\":15},{\"time\":\"2021-04-03T09:36:15.000Z\",\"value\":8},{\"time\":\"2021-04-03T09:36:16.000Z\",\"value\":8}]","payloadType":"json","x":830,"y":500,"wires":[["cd794d9b.4570e"]]},{"id":"cd794d9b.4570e","type":"function","z":"83a23089.dc697","name":"reformat data for bar chart","func":"/* required format...\n[{\n \"series\": [\"X\"],\n \"data\": [[5,6,9] ],\n \"labels\": [\"Jan\", \"Feb\", \"Mar\"]\n}]\n*/\n\n/* current format...\n[{\"time\":\"2021-04-03T09:35:32.000Z\",\"value\":3}]\n*/\n\nvar influxData = msg.payload;\nmsg.influxData = influxData; //keep a copy for reference\n\nvar data = []; //an array for bar chart data values\nvar labels = []; //an array for bar chart label values\nfor (let index = 0; index < influxData.length; index++) {\n const element = influxData[index]; //get this row of data\n const datetime = new Date(element.time); //get the time as a datetime object\n \n //get HH:mm and push it into the labels\n const time = datetime.getHours() + \":\" + datetime.getMinutes();\n labels.push(time);\n\n //push value into the data\n const value = element.value;\n data.push(value);\n}\n\n//set payload to the correct bar chart format...\nmsg.payload = [{\n \"series\": [\"X\"],\n \"data\": [data],\n \"labels\": labels\n}]\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":500,"wires":[["9e51b86c.9e1a88"]]},{"id":"9e51b86c.9e1a88","type":"debug","z":"83a23089.dc697","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1330,"y":500,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [3 April 2021 10:33 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/7 "2021-04-03T10:33:03Z")

</div>

@Steve-Mcl , Yes, data is not hourly. I injected the values to check the flow.

Will go through the demo flow & see if I understand the working 🙂 👍.

---

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [3 April 2021 12:05 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/8 "2021-04-03T12:05:37Z")

</div>

@Steve-Mcl , need more help. If I avoid the entire flow and directly inject the values in influxdb (ver 1.8.4). and then inject the values in chart using "last value - second last value". How should I write this query?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 April 2021 12:08 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/9 "2021-04-03T12:08:35Z")

</div>

Typically just set msg.topic to a nice friendly name and msg.payload to the value then pass it into the chart. However I'm not certain what a bar chart would look like in this case it's probably more suited to a line chart or a gauge.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 June 2021 12:09 UTC](https://discourse.nodered.org/t/display-hourly-production-in-bar-graph/43591/10 "2021-06-02T12:09:34Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
