# How to get chart Y set on maximum value?

**URL:** <https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [24 February 2022 19:25 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946 "2022-02-24T19:25:10Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [24 February 2022 19:25 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/1 "2022-02-24T19:25:11Z")

</div>

Hi, I'm passing by a switch node data from Openwather in this way:

```auto
[{	'series':["Media","Raffiche"],	"data":[[[payload.hourly].{'x':dt*1000,'y':wind_speed}], [[payload.hourly].{'x':dt*1000,'y':wind_gust}] ]	}]

```

But I got only half chart filled, how can I have the Y set to maximum value give into the array? Why now the maximum is only about the half of chart?  
Thanks  
 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/4704c331272c6ca58a76ad7f6877f41dfd9a14a7.png)  
 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/99964c32f6ed1b5ce8ac48ea6a38f5cec22dbc07.png)  
As you see I'm using a "flat" chart to save space vertically, and this result to less understandable result. If the Y can be set to maximum it would be enough..

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 February 2022 20:46 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/2 "2022-02-24T20:46:23Z")

</div>

What happens if you don't set the max y ? It should auto scale to fit.

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [24 February 2022 20:49 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/3 "2022-02-24T20:49:00Z")

</div>

The min and max of Y are empty for temperature, for wind the min is 0.  
It looks like the chart always put a margin from the highest value of data and the max of chart, which looks like double of the max (or min), do you confirm this?  
Thanks

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 February 2022 21:02 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/4 "2022-02-24T21:02:18Z")

</div>

no - it is probably an artefact of you having such a compressed y scale - it will usually either be the max value or just above it (it tries to use sensible scale steps) so in your pic above I guess you went just over 20 so it chose 0,20,40.

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [24 February 2022 21:26 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/5 "2022-02-24T21:26:05Z")

</div>

Yes it touch 22, but why 40? Can it be created with maximum on 22?  
I've no particular setting, values enter directy on node and no max set. How can I set it exactly to the maximum?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 February 2022 21:35 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/6 "2022-02-24T21:35:31Z")

</div>

You can set it to whatever max you want... You can change it dynamically if you have to buy using a ui\_control message - [node-red-dashboard/config-fields.md at master · node-red/node-red-dashboard · GitHub](https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md)  
Otherwise it tries to do it's best automatically - which as you see struggles when you don't give it much room vertically.

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [24 February 2022 21:54 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/7 "2022-02-24T21:54:40Z")

</div>

thank you for info!  
I't not really clear for me, I?m using a chart node, not a UI Widget, I don't understand if UI Widget is a generic name for all those nodes including chart. If yes you're suggesting me to include into msg a msg.ui\_chart={ymax:calculatedvalue}; ? Sorry there are no examples there

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 February 2022 22:06 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/8 "2022-02-24T22:06:16Z")

</div>

yes all the things on the dashboard are widgets. The chart is a widget.  
You can send a `msg.ui_control = { "ymax": 22 }` - or add a ui\_control property to you existing msg going into the chart node

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [25 February 2022 08:05 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/9 "2022-02-25T08:05:17Z")

</div>

> [@dceejay](#):
>
> `msg.ui_control = { "ymax": 22 }`

Works! But now I have another problem, how can I cut the decimal numbers on the Y?  
 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8ba6445814bff3847cb231497dc4239a80e4c40e.png)

I've tried to round the number.. and multiply it by 10.. so at least I'll see only .5, but if the result is rounded for defect, the Y data vales will exceed the maximum..  
Can the cutout command help?  
thanks

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [25 February 2022 08:24 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/10 "2022-02-25T08:24:13Z")

</div>

I've rounded the maximum to the ceiling and the lowest to the floor, and mutiply by ten, so in this case I should have numbers which are easy to divide. But in this chart it's not going well, can I reduce the legend on the Y to only 3 numbers? (max, 0, min)  
 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/0915bff9f389aa8e8c79c7b86ea5febe3335332e.png)

```auto

let cell0=[];
let cell1=[];
let data=[];
let massimo=0;
let minimo=0;
for (let i = 0; i < 48; i++) {
cell0.push({y:((Math.round(msg.payload.hourly[i].temp*10))/10),x:msg.payload.hourly[i].dt * 1000});
cell1.push({y:((Math.round(msg.payload.hourly[i].feels_like*10))/10),x:msg.payload.hourly[i].dt * 1000});
if (msg.payload.hourly[i].temp>massimo) {massimo=msg.payload.hourly[i].temp;}
if (msg.payload.hourly[i].feels_like>massimo) {massimo=msg.payload.hourly[i].feels_like;}
if (msg.payload.hourly[i].temp<minimo) {minimo=msg.payload.hourly[i].temp;}
if (msg.payload.hourly[i].feels_like<minimo) {minimo=msg.payload.hourly[i].feels_like;}
}
massimo=(Math.ceil(massimo/10))*10;
minimo=(Math.floor(minimo/10))*10;
data[0]=cell0;
data[1]=cell1;
cmsg={payload:[]};
cmsg.payload[0]={};
cmsg.payload[0].data=data;
cmsg.payload[0].series = ["Reale","Percepita"];
cmsg.ui_control = { "ymax": massimo, "ymin":minimo };

return cmsg;

```

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [25 February 2022 08:37 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/11 "2022-02-25T08:37:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [27 February 2022 11:28 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/12 "2022-02-27T11:28:46Z")

</div>

there is any solution to get proper values on the Y ? thanks

---

<div class="post-metadata">

**Author:** ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)\
**Post date:** [28 February 2022 22:28 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/13 "2022-02-28T22:28:05Z")

</div>

any solution for this?

---

<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:** [2 March 2022 16:04 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/14 "2022-03-02T16:04:13Z")

</div>

The dashboard chart widget is a simple way to get charts on the dashboard. In order to make it easy to use it makes guesses about what you want and tries to provide useful charts. If the algorithms used are not suitable for you then there are other, more configurable, ways of providing charts. If you search the forum then you should be able to find suggestions.  
Alternatively, if you think you can produce an improved algorithm for Y axis scaling then I am sure a PR would be considered positively.

---

<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:** [16 March 2022 16:04 UTC](https://discourse.nodered.org/t/how-to-get-chart-y-set-on-maximum-value/58946/15 "2022-03-16T16:04:51Z")

</div>

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