Plot unique x-y points

Hi all,

I am somewhat new to Node-Red and Dashboard-2. I have an ongoing stream of integer x-y points from 0-100 going into a graph over time. I would like to plot them only if the x-y point is unique. Any ideas on how to achieve this? I seek to minimize the redundant points to keep the plotting fast over months of data acquisition.

Thanks!

I think you would have to use javascript in a function node to do this, using a 2 dimensional array 100x100 to hold an indication of which points that had already been plotted.

Should be possible saving plotted position in a context var, then using a switch node to only allow non plotted data through.
e.g.

[{"id":"16c2839487757a01","type":"inject","z":"d1395164b4eec73e","name":"Scatter Data","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"x\":$round($random()*10),\"y\":$round($random()*10)}","payloadType":"jsonata","x":200,"y":100,"wires":[["9f567527466a60eb"]]},{"id":"9f567527466a60eb","type":"switch","z":"d1395164b4eec73e","name":"","property":"data[msg.payload.x][msg.payload.y]","propertyType":"flow","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":390,"y":100,"wires":[[],["75abf3e38554e4b1"]]},{"id":"75abf3e38554e4b1","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"data[msg.payload.x][msg.payload.y]","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":100,"wires":[["d6ddc83bcd4de04a"]]},{"id":"d6ddc83bcd4de04a","type":"ui-chart","z":"d1395164b4eec73e","group":"b429518aee48a6fb","name":"Chart: Scatter","label":"Scatter Plot Example","order":1,"chartType":"scatter","category":"","categoryType":"property","xAxisLabel":"x","xAxisProperty":"x","xAxisPropertyType":"property","xAxisType":"linear","xAxisFormat":"","xAxisFormatType":"auto","yAxisLabel":"y","yAxisProperty":"y","ymin":"0","ymax":"10","action":"append","pointShape":"circle","pointRadius":4,"showLegend":true,"removeOlder":1,"removeOlderUnit":"3600","removeOlderPoints":"","colors":["#0095ff","#ff0000","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"textColor":["#666666"],"textColorDefault":true,"gridColor":["#e5e5e5"],"gridColorDefault":true,"width":6,"height":8,"className":"","x":620,"y":160,"wires":[["afe5d6d82530d384"]]},{"id":"aa0ac5025fc32d7f","type":"inject","z":"d1395164b4eec73e","name":"Clear Data","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"json","x":200,"y":140,"wires":[["d6ddc83bcd4de04a"]]},{"id":"afe5d6d82530d384","type":"debug","z":"d1395164b4eec73e","name":"debug 2565","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":140,"wires":[]},{"id":"b429518aee48a6fb","type":"ui-group","name":"Chart Examples","page":"d0621b8f20aee671","width":"6","height":"1","order":1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"d0621b8f20aee671","type":"ui-page","name":"Charts","ui":"1805777f90e92057","path":"/charts","icon":"home","layout":"notebook","theme":"5075a7d8e4947586","order":3,"className":"","visible":"true","disabled":"false"},{"id":"1805777f90e92057","type":"ui-base","name":"dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false},{"id":"5075a7d8e4947586","type":"ui-theme","name":"Default Theme","colors":{"surface":"#ffffff","primary":"#0094CE","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

No coding required.

2 Likes

Much better than my suggestion.

This is brilliant. Thank you so much! I didn't realize one could use the flow variable like this, so it makes for a nice education, too. Cheers!

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