Try this flow - I tested this with a test of 5 bars. On the 6th, it drops the first one and add the last one. You can change it to 30 to keep a running set of 30 days data.
[{"id":"cdcb31eb2f25ce22","type":"inject","z":"d84b176e12749a08","name":"Machine 1 Day 1","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 1","x":204.83456420898438,"y":2749.591796875,"wires":[["a778b74aafec4062"]]},{"id":"a778b74aafec4062","type":"change","z":"d84b176e12749a08","name":"Day 1","rules":[{"t":"set","p":"date","pt":"msg","to":"$moment(timestamp).tz(\"America/Chicago\").format(\"MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":418.1286926269531,"y":2793.477828979492,"wires":[["bb29bd8a8c4f8516"]]},{"id":"d0cd9e4acb65a21f","type":"inject","z":"d84b176e12749a08","name":"Machine 2 Day 1","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":204.83456420898438,"y":2790.536651611328,"wires":[["a778b74aafec4062"]]},{"id":"525c671130d800e0","type":"inject","z":"d84b176e12749a08","name":"Machine 3 Day 1","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 3","x":204.83456420898438,"y":2836.536651611328,"wires":[["a778b74aafec4062"]]},{"id":"bb29bd8a8c4f8516","type":"junction","z":"d84b176e12749a08","x":577.5800737738609,"y":3163.905901223421,"wires":[["f93aa849d2691722","95529f58c0531a26"]]},{"id":"dd40a0c12802d59f","type":"change","z":"d84b176e12749a08","name":"Day 2","rules":[{"t":"set","p":"date","pt":"msg","to":"$moment(timestamp).tz(\"America/Chicago\").add(1, \"days\").format(\"MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":418.1286926269531,"y":2926.3638610839844,"wires":[["bb29bd8a8c4f8516"]]},{"id":"dcc2741547a1f307","type":"change","z":"d84b176e12749a08","name":"Day 3","rules":[{"t":"set","p":"date","pt":"msg","to":"$moment(timestamp).tz(\"America/Chicago\").add(2, \"days\").format(\"MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":418.1286926269531,"y":3065.3638439178467,"wires":[["bb29bd8a8c4f8516"]]},{"id":"d623e86676f4793e","type":"change","z":"d84b176e12749a08","name":"Day 4","rules":[{"t":"set","p":"date","pt":"msg","to":"$moment(timestamp).tz(\"America/Chicago\").add(3, \"days\").format(\"MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":404.8345642089844,"y":3224.591796875,"wires":[["bb29bd8a8c4f8516"]]},{"id":"7c0e25b754dea6bf","type":"change","z":"d84b176e12749a08","name":"Day 5","rules":[{"t":"set","p":"date","pt":"msg","to":"$moment(timestamp).tz(\"America/Chicago\").add(4, \"days\").format(\"MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":410.8345642089844,"y":3377.591796875,"wires":[["bb29bd8a8c4f8516"]]},{"id":"613f4487bb1aca73","type":"change","z":"d84b176e12749a08","name":"Day 6","rules":[{"t":"set","p":"date","pt":"msg","to":"$moment(timestamp).tz(\"America/Chicago\").add(6, \"days\").format(\"MM-DD\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":413.8345642089844,"y":3532.47412109375,"wires":[["bb29bd8a8c4f8516"]]},{"id":"f93aa849d2691722","type":"function","z":"d84b176e12749a08","d":true,"name":"Get Chart Data","func":"// --- Retrieve or initialize stored data ---\nlet chartData = flow.get('chartdata') || [];\n\n// Optional reset\nif (msg.reset || msg.topic === 'reset') {\n chartData = [];\n}\n\n// Extract incoming message\nconst date = String(msg.date);\nconst machine = String(msg.topic); // machine name\nconst count = Number(msg.count) || 0;\n\n//Track today's starts\nlet todayCount = '';\n\n// --- Update or insert record ---\nlet found = false;\nfor (let row of chartData) {\n if (row.date === date && row.machine === machine) {\n row.starts += count; // accumulate count\n todayCount = row.starts.toString(); // todya's count\n found = true;\n break;\n }\n}\n\nif (!found) {\n chartData.push({ date: date, machine: machine, starts: count });\n todayCount = count.toString(); // todya's count\n}\n\n// Save updated data in flow\nflow.set('chartdata', chartData);\n\n// --- Output flat array for Dashboard 2 ---\nmsg.payload = chartData;\nmsg.todayCount = todayCount;\n\n// Optional debug\nmsg.chartData = chartData;\n\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\nvar count = flow.get('count1');","finalize":"","libs":[],"x":715.0001525878906,"y":3094.591796875,"wires":[["c7d0f3708a5187da","d66e4f7c17fc116d"]]},{"id":"95529f58c0531a26","type":"function","z":"d84b176e12749a08","name":"Get Chart Data 30 days","func":"// --- Retrieve or initialize stored data ---\nlet chartData = flow.get('chartdata') || [];\n\n// Optional reset\nif (msg.reset || msg.topic === 'reset') {\n chartData = [];\n}\n\n// Extract incoming message\nconst date = String(msg.date);\nconst machine = String(msg.topic); // machine name\nconst count = Number(msg.count) || 0;\n\n// Track today's starts\nlet todayCount = '';\n\n// --- Update or insert record ---\nlet found = false;\nfor (let row of chartData) {\n if (row.date === date && row.machine === machine) {\n row.starts += count; // accumulate count\n todayCount = row.machine + ': ' + row.starts.toString(); // today's count\n found = true;\n break;\n }\n}\n\nif (!found) {\n if (chartData.length >= 5) { // Change 5 to 30 - this is for testing\n const firstRow = chartData.shift(); // drop the first element\n }\n chartData.push({ date: date, machine: machine, starts: count });\n todayCount = machine + ': ' + count.toString(); // today's count\n}\n\n// Save updated data in flow\nflow.set('chartdata', chartData);\n\n// --- Output flat array for Dashboard 2 ---\nmsg.payload = chartData;\nmsg.todayCount = todayCount;\n\n// Optional debug\nmsg.chartData = chartData;\n\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\nvar count = flow.get('count1');","finalize":"","libs":[],"x":770.8346252441406,"y":3164.4189453125,"wires":[["d66e4f7c17fc116d"]]},{"id":"407676baf1fbb4af","type":"inject","z":"d84b176e12749a08","name":"Machine 1 (Day 2)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 1","x":214.83456420898438,"y":2887.477847099304,"wires":[["dd40a0c12802d59f"]]},{"id":"a2fe8cb06e81a09b","type":"inject","z":"d84b176e12749a08","name":"Machine 2 (Day 2)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":214.83456420898438,"y":2925.536651611328,"wires":[["dd40a0c12802d59f"]]},{"id":"92e078556e16bb49","type":"inject","z":"d84b176e12749a08","name":"Machine 3 (Day 2)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":214.83456420898438,"y":2961.536651611328,"wires":[["dd40a0c12802d59f"]]},{"id":"e027ea0db2f5ae23","type":"inject","z":"d84b176e12749a08","name":"Machine 1 (Day 3)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 1","x":214.83456420898438,"y":3022.536651611328,"wires":[["dcc2741547a1f307"]]},{"id":"dfe39f75f1fddffe","type":"inject","z":"d84b176e12749a08","name":"Machine 2 (Day 3)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":214.83456420898438,"y":3063.5954599380493,"wires":[["dcc2741547a1f307"]]},{"id":"8fb8c001a9735507","type":"inject","z":"d84b176e12749a08","name":"Machine 3 (Day 3)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":214.83456420898438,"y":3105.595458984375,"wires":[["dcc2741547a1f307"]]},{"id":"aac28d3dbe0e5e26","type":"inject","z":"d84b176e12749a08","name":"Machine 1 (Day 4)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 1","x":201.54043579101562,"y":3181.7646045684814,"wires":[["d623e86676f4793e"]]},{"id":"5e36c4db93fbf364","type":"inject","z":"d84b176e12749a08","name":"Machine 2 (Day 4)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":201.54043579101562,"y":3222.8234128952026,"wires":[["d623e86676f4793e"]]},{"id":"7214f2169084fb07","type":"inject","z":"d84b176e12749a08","name":"Machine 3 (Day 4)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":201.54043579101562,"y":3264.8234119415283,"wires":[["d623e86676f4793e"]]},{"id":"2c1227c4e88d1970","type":"inject","z":"d84b176e12749a08","name":"Machine 1 (Day 5)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 1","x":207.54043579101562,"y":3334.7646045684814,"wires":[["7c0e25b754dea6bf"]]},{"id":"ef5839bcadc33f45","type":"inject","z":"d84b176e12749a08","name":"Machine 2 (Day 5)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":207.54043579101562,"y":3375.8234128952026,"wires":[["7c0e25b754dea6bf"]]},{"id":"3d018c74499001d6","type":"inject","z":"d84b176e12749a08","name":"Machine 3 (Day 5)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":207.54043579101562,"y":3417.8234119415283,"wires":[["7c0e25b754dea6bf"]]},{"id":"b040c9eb15d938aa","type":"inject","z":"d84b176e12749a08","name":"Machine 1 (Day 6)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 1","x":210.54043579101562,"y":3489.6469287872314,"wires":[["613f4487bb1aca73"]]},{"id":"1e5207b2bc9c8aa4","type":"inject","z":"d84b176e12749a08","name":"Machine 2 (Day 6)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":210.54043579101562,"y":3530.7057371139526,"wires":[["613f4487bb1aca73"]]},{"id":"35fa29c5bc437878","type":"inject","z":"d84b176e12749a08","name":"Machine 3 (Day 6)","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"},{"p":"count","v":"10","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Machine 2","x":210.54043579101562,"y":3572.7057361602783,"wires":[["613f4487bb1aca73"]]},{"id":"c7d0f3708a5187da","type":"debug","z":"d84b176e12749a08","name":"Debug Chart Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":714.6546936035156,"y":3041.75537109375,"wires":[]},{"id":"d66e4f7c17fc116d","type":"ui-chart","z":"d84b176e12749a08","group":"fd6045295841c382","name":"Count STarts","label":"Machine Starts","order":3,"chartType":"bar","category":"machine","categoryType":"property","xAxisLabel":"Date","xAxisProperty":"date","xAxisPropertyType":"property","xAxisType":"category","xAxisFormat":"","xAxisFormatType":"auto","xmin":"","xmax":"","yAxisLabel":"Starts","yAxisProperty":"starts","yAxisPropertyType":"property","ymin":"","ymax":"","bins":"","action":"replace","stackSeries":false,"pointShape":"circle","pointRadius":4,"showLegend":true,"removeOlder":1,"removeOlderUnit":"3600","removeOlderPoints":"","colors":["#0095ff","#ff0000","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"textColor":["#ffffff"],"textColorDefault":false,"gridColor":["#e5e5e5"],"gridColorDefault":true,"width":6,"height":8,"className":"","interpolation":"linear","x":999.1286888122559,"y":3162.477783203125,"wires":[["f4c7cc94749700f8"]]},{"id":"1fc05c88906e8a89","type":"change","z":"d84b176e12749a08","name":"Delete Flow Variables","rules":[{"t":"delete","p":"oldCount","pt":"flow"},{"t":"delete","p":"oldDate","pt":"flow"},{"t":"delete","p":"chartdata","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":951.6582336425781,"y":2965.7294921875,"wires":[["d66e4f7c17fc116d"]]},{"id":"f4c7cc94749700f8","type":"debug","z":"d84b176e12749a08","name":"debug 23","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1167.6433410644531,"y":3160.748046875,"wires":[]},{"id":"dcd1f46bcbe83c0f","type":"inject","z":"d84b176e12749a08","name":"Clear Data","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"json","x":750.7170677185059,"y":2966.00732421875,"wires":[["1fc05c88906e8a89"]]},{"id":"fd6045295841c382","type":"ui-group","name":"db2 bar wip share","page":"ccc312f7c9d7a917","width":"30","height":1,"order":1,"showTitle":true,"className":"","visible":"true","disabled":"false","groupType":"default"},{"id":"ccc312f7c9d7a917","type":"ui-page","name":"db2 bar wip share","ui":"de5759a313e7ad79","path":"/page26","icon":" ","layout":"tabs","theme":"682b37bffc90cac5","breakpoints":[{"name":"Default","px":"0","cols":"9"},{"name":"Tablet","px":"576","cols":"9"},{"name":"Small Desktop","px":"768","cols":"9"},{"name":"Desktop","px":"1024","cols":"12"}],"order":23,"className":"","visible":"true","disabled":"false"},{"id":"de5759a313e7ad79","type":"ui-base","name":"Node-RED Dashboard DB2","path":"/dashboard","appIcon":"","includeClientData":false,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"headerContent":"dashboard","navigationStyle":"fixed","titleBarStyle":"default","showReconnectNotification":true,"notificationDisplayTime":5,"showDisconnectNotification":true,"allowInstall":true},{"id":"682b37bffc90cac5","type":"ui-theme","name":"Rakesh Dark","colors":{"surface":"#097479","primary":"#337278","bgPage":"#000000","groupBg":"#000000","groupOutline":"#337278"},"sizes":{"density":"comfortable","pagePadding":"6px","groupGap":"5px","groupBorderRadius":"1px","widgetGap":"6px"}},{"id":"fe38d4a254586020","type":"global-config","env":[],"modules":{"@flowfuse/node-red-dashboard":"1.25.0"}}]
Here is where you need to change it to 30…
if (!found) {
if (chartData.length >= 5) { // Change 5 to 30 - this is for testing
const firstRow = chartData.shift(); // drop the first element
}
chartData.push({ date: date, machine: machine, starts: count });
todayCount = machine + ': ' + count.toString(); // today's count
}
I also added in the Machine name to the today’s count so it should take into account different machines.
UPDATE: This does not work for multiple machines on the same chart (it will work for a single machine).