# Plot unique x-y points

**URL:** <https://discourse.nodered.org/t/plot-unique-x-y-points/90351>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [22 August 2024 22:15 UTC](https://discourse.nodered.org/t/plot-unique-x-y-points/90351 "2024-08-22T22:15:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanderson](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@sanderson](https://discourse.nodered.org/u/sanderson)\
**Post date:** [22 August 2024 22:15 UTC](https://discourse.nodered.org/t/plot-unique-x-y-points/90351/1 "2024-08-22T22:15:02Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 August 2024 08:03 UTC](https://discourse.nodered.org/t/plot-unique-x-y-points/90351/2 "2024-08-23T08:03:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 August 2024 09:08 UTC](https://discourse.nodered.org/t/plot-unique-x-y-points/90351/3 "2024-08-23T09:08:13Z")

</div>

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

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 August 2024 09:50 UTC](https://discourse.nodered.org/t/plot-unique-x-y-points/90351/4 "2024-08-23T09:50:45Z")

</div>

Much better than my suggestion.

---

<div class="post-metadata">

**Author:** ![sanderson](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@sanderson](https://discourse.nodered.org/u/sanderson)\
**Post date:** [23 August 2024 21:08 UTC](https://discourse.nodered.org/t/plot-unique-x-y-points/90351/5 "2024-08-23T21:08:24Z")

</div>

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!

---

<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:** [6 September 2024 21:08 UTC](https://discourse.nodered.org/t/plot-unique-x-y-points/90351/6 "2024-09-06T21:08:52Z")

</div>

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