# Chart Node Auto-Scaling

**URL:** <https://discourse.nodered.org/t/chart-node-auto-scaling/84450>\
**Category:** Dashboard\
**Created:** [10 January 2024 16:36 UTC](https://discourse.nodered.org/t/chart-node-auto-scaling/84450 "2024-01-10T16:36:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MakerMan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@MakerMan](https://discourse.nodered.org/u/MakerMan)\
**Post date:** [10 January 2024 16:36 UTC](https://discourse.nodered.org/t/chart-node-auto-scaling/84450/1 "2024-01-10T16:36:54Z")

</div>

By default the chart will auto-scale on the Y axis.

Or I can specify axes values with

```
msg.ui_control = { "ymax": (scale_max), "ymin": (scale_min), "stepSize": '0.5' };

```

I'm trying to prevent a chart Y axis being too 'short'. Ideally there would be a 'minimum range' value for the Y axis, but absent being able to set that I need to ensure that ymax less ymin is not less than say, 10.

I have a function node to do this, but I'd like to be able to revert. to auto-scaling with the logic

If maximum\_value - minimum\_value \< 10  
Set axis values with function node  
Else  
Set axis values to auto-scale

So how do I return a chart to auto-scale the Y axis after using 'msg.ui\_control', please?

---

<div class="post-metadata">

**Author:** ![MakerMan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@MakerMan](https://discourse.nodered.org/u/MakerMan)\
**Post date:** [10 January 2024 17:29 UTC](https://discourse.nodered.org/t/chart-node-auto-scaling/84450/2 "2024-01-10T17:29:00Z")

</div>

Am I correct in understanding that if I use

msg.ui\_control = { "suggestedMax": scale\_max, "suggestedMin": scale\_min };

That this will allow auto-scaling to continue to function?

---

<div class="post-metadata">

**Author:** ![MakerMan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@MakerMan](https://discourse.nodered.org/u/MakerMan)\
**Post date:** [11 January 2024 16:15 UTC](https://discourse.nodered.org/t/chart-node-auto-scaling/84450/3 "2024-01-11T16:15:42Z")

</div>

I can't get this to work!

Chart of 24 hour temperature ...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3bec656bfb3aa1d1289a4815115c92298bd3a0cf.png)

I am sending  
msg.ui\_control = {"suggestedMax":scale\_max,"suggestedMin":scale\_min};

where scale\_max = 7 and scale\_min = 2

But the chart is auto-scaling from 0 to 6.

I thought that scale minimum would be "Math.min(dataMin, suggestedMin)" and that scale maximum would be "Math.max(dataMax, suggestedMax)" but clearly I'm missing something about how this is supposed to work.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [11 January 2024 17:18 UTC](https://discourse.nodered.org/t/chart-node-auto-scaling/84450/4 "2024-01-11T17:18:41Z")

</div>

With function node:

```auto
msg.ui_control = {
    options:{
        scales: {
            yAxes: [
                {
                ticks: {
                        suggestedMin: 50,
                        suggestedMax: 100
                    }
                }
            ]                
        }
    }
};

delete msg.payload;
return msg;

```

---

<div class="post-metadata">

**Author:** ![MakerMan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@MakerMan](https://discourse.nodered.org/u/MakerMan)\
**Post date:** [11 January 2024 21:35 UTC](https://discourse.nodered.org/t/chart-node-auto-scaling/84450/5 "2024-01-11T21:35:48Z")

</div>

I was searching Github to try to find that. Many thanks.

---

<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:** [25 January 2024 21:36 UTC](https://discourse.nodered.org/t/chart-node-auto-scaling/84450/6 "2024-01-25T21:36:31Z")

</div>

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