I tried to use this dynamic scatter/bubble plot (adding the data and reset at some point) and got it working. In my solution I update the plot every minute and other plot is updated every hour. I'm doing this because I don't want to exhaust the node-red with large amount of data.
I have one problem. When I go to the dashboard page (or reload it) the plot is updated only after the one minute or one hour update has passed and before that it shows only the default screen "this will be ignored". How this can be prevented so that it shows the plot straight away when the page is reloaded.
One solution is to update the plot for example every 5s, but there would be 17 280x2 data points in one day and with the other plot I was thinking to reset it every year so 6 307 200x2 data point
Would this exhaust the node-red?
Other solution is to inject the node whenever the node-red dashboard is reloaded. Can this be made somehow?
One minute update plot:
[{"id":"c42b1a5f.948b78","type":"debug","z":"86c9171.40beee8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1130,"y":180,"wires":[]},{"id":"dca3aba9.d2b7e8","type":"debug","z":"86c9171.40beee8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1450,"y":100,"wires":[]},{"id":"9125df13.c99f4","type":"function","z":"86c9171.40beee8","name":"Build two cumulating random datasets","func":"// this is where you define the legend for \n// the datasets\nvar title = \"ID3\";\nvar legend1 = \"Latauskäyrä\";\n\n\n// variables to be used to \nvar i, x, y, r, data1;\n// initialise the counter to 0 if it doesn't exist already\nvar data1 = flow.get('data1')||'';\n\n\nvar count = flow.get('count')||0;\ncount += 1;\nx = global.get('ID3soc');\ny = global.get('ID3latausTeho');\nr = 1;\nif (count > 1440) {\n count = 1;\n data1 = '{x: \"x\", y: \"y\", r: \"r\"},'; // Force the size of the\n} \n// store the value back\nflow.set('count',count);\n// make it part of the outgoing msg object\nmsg.count = count;\n\n// for dataset #1\n// this code generates one x/y point \n// between -100 and +100 and a random \n//size between 1 and 10\n//node.warn(\"db1=\"+data1);\nx = global.get('ID3soc');\ny = global.get('ID3latausTeho');\nr = 1;\ndata1 += \"{x: \"+x+\", y: \"+y+\", r: \"+r+\"},\";\n//node.warn(\"db2=\"+data1);\n// this line removes the last comma to end the dataset\ndata1 = data1.replace(/^(.*),(.*?)$/, '$1')\n\n// Now we build msg.payload\nmsg.payload = { \"title\" : title,\n \"legend1\" : legend1,\n \"data1\" : data1}\n \ndata1 += \",\";\n\n\nflow.set([\"data1\"], [data1]);\nreturn msg;\n\n","outputs":1,"noerr":0,"x":510,"y":100,"wires":[["8e767188.51d14","3846208e.4e493"]]},{"id":"8e767188.51d14","type":"debug","z":"86c9171.40beee8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":790,"y":180,"wires":[]},{"id":"3846208e.4e493","type":"template","z":"86c9171.40beee8","name":"Create the msg.template to use","field":"template","fieldType":"msg","format":"html","syntax":"mustache","template":"<canvas id=\"bubble-chart\" width=\"1\" height=\"1\" style=\"border:1px solid #ffffff;\"></canvas>\n\n<script>\nnew Chart(document.getElementById(\"bubble-chart\"), {\n type: 'bubble',\n data: {\n labels: \"label\",\n datasets: [\n {\n label: \"{{{payload.legend1}}}\",\n backgroundColor: \"rgba(255, 255, 255, 0.3000)\",\n borderColor: \"rgba(255,255,255,0.3000)\",\n data: [\n {{{payload.data1}}}\n ]\n }\n ]\n },\n options: {\n animation: false,\n legend: {\n display: true,\n labels: {\n fontColor: 'rgb(255, 255, 255)'\n }\n },\n title: {\n display: true,\n text: '{{{payload.title}}}',\n fontColor: 'rgb(255, 255, 255)'\n }, scales: {\n yAxes: [{ \n scaleLabel: {\n display: true,\n labelString: \"Latausteho [kW]\",\n fontColor: 'rgb(255, 255, 255)'\n }\n }],\n xAxes: [{ \n scaleLabel: {\n display: true,\n labelString: \"SOC [%]\",\n fontColor: 'rgb(255, 255, 255)'\n }\n }]\n }\n }\n});\n\n</script>\n","output":"str","x":850,"y":100,"wires":[["c42b1a5f.948b78","11b0ec5.6409c14"]]},{"id":"11b0ec5.6409c14","type":"ui_template","z":"86c9171.40beee8","group":"bfbd69a3.7f8268","name":"ChargingPlot","order":1,"width":12,"height":11,"format":"this will be ignored","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":1150,"y":100,"wires":[["dca3aba9.d2b7e8"]]},{"id":"7a065a8d.e1db44","type":"inject","z":"86c9171.40beee8","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":100,"wires":[["9125df13.c99f4"]]},{"id":"bfbd69a3.7f8268","type":"ui_group","z":"","name":"ID3 latausgraafi","tab":"41d22295.86ebec","order":1,"disp":false,"width":"12","collapse":false},{"id":"41d22295.86ebec","type":"ui_tab","z":"","name":"ID3 latausgraafi","icon":"dashboard","order":3,"disabled":false,"hidden":false}]
One hour update plot
[{"id":"a596ec6f.f76ff","type":"function","z":"64ff8ec1.57aa1","name":"Build two cumulating random datasets","func":"// this is where you define the legend for \n// the datasets\nvar title = \"ID3 kokonaisrange vs. lämpötila\";\nvar legend1 = \"Kokonaisrange\";\n\n\n// variables to be used to \nvar i, x, y, r, data1;\n// initialise the counter to 0 if it doesn't exist already\nvar data1 = flow.get('data1')||'';\n\n\nvar count = flow.get('count')||0;\ncount += 1;\nx = global.get('ulkolampotila');\ny = global.get('ID3range')/global.get('ID3soc')*100;\nr = 1;\nif (count > 2000) {\n count = 1;\n data1 = '{x: \"x\", y: \"y\", r: \"r\"},';\n} \n// store the value back\nflow.set('count',count);\n// make it part of the outgoing msg object\nmsg.count = count;\n\n// for dataset #1\n// this code generates one x/y point \n// between -100 and +100 and a random \n//size between 1 and 10\n//node.warn(\"db1=\"+data1);\n\ndata1 += \"{x: \"+x+\", y: \"+y+\", r: \"+r+\"},\";\n//node.warn(\"db2=\"+data1);\n// this line removes the last comma to end the dataset\ndata1 = data1.replace(/^(.*),(.*?)$/, '$1')\n\n// Now we build msg.payload\nmsg.payload = { \"title\" : title,\n \"legend1\" : legend1,\n \"data1\" : data1}\n \ndata1 += \",\";\n\n\nflow.set([\"data1\"], [data1]);\nreturn msg;\n\n","outputs":1,"noerr":0,"x":390,"y":100,"wires":[["968244b0.400ae8","64c23a17.8a2964"]]},{"id":"968244b0.400ae8","type":"template","z":"64ff8ec1.57aa1","name":"Create the msg.template to use","field":"template","fieldType":"msg","format":"html","syntax":"mustache","template":"<canvas id=\"bubble-chart\" width=\"1\" height=\"1\" style=\"border:1px solid #ffffff;\"></canvas>\n\n<script>\nnew Chart(document.getElementById(\"bubble-chart\"), {\n type: 'bubble',\n data: {\n labels: \"label\",\n datasets: [\n {\n label: \"{{{payload.legend1}}}\",\n backgroundColor: \"rgba(255, 255, 255, 0.3000)\",\n borderColor: \"rgba(255,255,255,0.3000)\",\n data: [\n {{{payload.data1}}}\n ]\n }\n ]\n },\n options: {\n animation: false,\n legend: {\n display: true,\n labels: {\n fontColor: 'rgb(255, 255, 255)'\n }\n },\n title: {\n display: true,\n text: '{{{payload.title}}}',\n fontColor: 'rgb(255, 255, 255)'\n }, scales: {\n yAxes: [{ \n scaleLabel: {\n display: true,\n labelString: \"Kokonaisrange [km]\",\n fontColor: 'rgb(255, 255, 255)'\n }\n }],\n xAxes: [{ \n scaleLabel: {\n display: true,\n labelString: \"Ulkolämpötila [C]\",\n fontColor: 'rgb(255, 255, 255)'\n }\n }]\n }\n }\n});\n\n</script>\n","output":"str","x":810,"y":100,"wires":[["273d40fc.ac60a"]]},{"id":"cc56e7fe.b85638","type":"inject","z":"64ff8ec1.57aa1","name":"","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":100,"wires":[["a596ec6f.f76ff"]]},{"id":"273d40fc.ac60a","type":"ui_template","z":"64ff8ec1.57aa1","group":"1551020.ad467fe","name":"TotalRange","order":1,"width":"0","height":"0","format":"this will be ignored","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":1140,"y":100,"wires":[[]]},{"id":"64c23a17.8a2964","type":"debug","z":"64ff8ec1.57aa1","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":700,"y":180,"wires":[]},{"id":"1551020.ad467fe","type":"ui_group","z":"","name":"ID3 kokonaisrange","tab":"90f09cb7.cba8c","order":1,"disp":true,"width":12,"collapse":false},{"id":"90f09cb7.cba8c","type":"ui_tab","z":"","name":"ID3 kokonaisrange","icon":"dashboard","order":11,"disabled":false,"hidden":false}]