# Dynamic routing to widgets

**URL:** <https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416>\
**Category:** Dashboard\
**Created:** [14 August 2022 09:25 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416 "2022-08-14T09:25:26Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![alf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alf/32/18315_2.png) [@alf](https://discourse.nodered.org/u/alf)\
**Post date:** [19 August 2022 08:27 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/22 "2022-08-19T08:27:19Z")

</div>

OMG : this not only works, but so easy - and visually great !!!!!  
Thank you for this !! It is really something else !! Saves effing tons of work and cluttered dashes

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [19 August 2022 08:36 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/23 "2022-08-19T08:36:12Z")

</div>

> [@alf](#):
>
> and visually great !!!!!

We need a screenshot Alf!!!

---

<div class="post-metadata">

**Author:** ![alf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alf/32/18315_2.png) [@alf](https://discourse.nodered.org/u/alf)\
**Post date:** [19 August 2022 08:51 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/24 "2022-08-19T08:51:31Z")

</div>

Dude - I just deleted and started anew - there really isn't much to see here - I will post when I deploy irl (sometime next week hopefully).

 ![sc1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d1560fb0a69da29e0dd1176229a7c530efb42f9.png)  
 ![sc2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/80a42ece136953591dafef262a2e9e986d8554e3.png)  
 ![sc3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/db07717bbdae51ea1b9573f89dd6b66cc373a97c.png)

---

<div class="post-metadata">

**Author:** ![tve](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tve/32/59475_2.png) [@tve](https://discourse.nodered.org/u/tve)\
**Post date:** [22 August 2022 16:30 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/25 "2022-08-22T16:30:00Z")

</div>

NB: the latest version of FD fixes the issue with missing `labels`: if you remove labels now you should have no legend and a bit more space for the plot itself. Whether you prefer that or not is up to you....

Ughh, I now realize the on-hover tooltip shows "series 1", I need to fix that 🙄

---

<div class="post-metadata">

**Author:** ![alf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alf/32/18315_2.png) [@alf](https://discourse.nodered.org/u/alf)\
**Post date:** [23 August 2022 08:27 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/26 "2022-08-23T08:27:52Z")

</div>

Here are screenshots from the actual POC with 5 sensors - there will be 5 more asap.  
So easy ....

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/e/de43af7885b37dafc886fef68fdc49544b58aa0f.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/6547375a7bd4ead9aef5677bed3db2c213e598a2.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/1/81c5bcdd57a34927b9181d925e830830897539ee.png)

---

<div class="post-metadata">

**Author:** ![alf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alf/32/18315_2.png) [@alf](https://discourse.nodered.org/u/alf)\
**Post date:** [23 August 2022 08:32 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/27 "2022-08-23T08:32:18Z")

</div>

Dude - no biggie - I am just over the moon that I don't have to individually program and layout for all individual sensors..  
I will say one thing I just realised - it seems the timelines only get/accept data as long as the window to the dash is open - the nodes themselves do not retain data for a small period of time ?  
Is that on your development-list of features ?

---

<div class="post-metadata">

**Author:** ![tve](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tve/32/59475_2.png) [@tve](https://discourse.nodered.org/u/tve)\
**Post date:** [23 August 2022 15:41 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/28 "2022-08-23T15:41:50Z")

</div>

> [@alf](#):
>
> Is that on your development-list of features ?

Yes, I'm not sure yet what it should exactly do.

From what I see your data is all in-memory, so you need to buffer it explicitly. Currently you are sending one data point at a time to the widget. You need to build up the array of all data points to display and send it the full array.

So write a "data buffer" function node that, for each topic (i.e. plot) collects the last N data points in an array saved in the node context. Something like: **(untested)**:

```javascript
let data = node.get(msg.topic) || [] // get saved data for this topic
data.push(msg.data) // append new data point
while (data.length > 100) data.shift() // remove excess data points
node.set(msg.topic, data) // save the new dataset
msg.data = data // output the full dataset
return msg

```

What's currently missing is a way to efficiently transmit this to the dashboard, i.e., not send all the data every time. Although, you won't really notice any difference...

---

<div class="post-metadata">

**Author:** ![alf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alf/32/18315_2.png) [@alf](https://discourse.nodered.org/u/alf)\
**Post date:** [23 August 2022 21:09 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/29 "2022-08-23T21:09:03Z")

</div>

Works like a charm with one small mod - context.get and context.set - not node.get/set this time.

Mvh  
Alf Møllerud (+47 93267132)

---

<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 2022 21:09 UTC](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416/30 "2022-09-06T21:09:45Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/dynamic-routing-to-widgets/66416.md?page=1)
