Chart Ymax buffer based on payload

Hello everyone,

I have a chart that has no margins and so if I have a high value it shows right at the top. Is there a way to add 10 points/values to the incoming value so I get a bit of a buffer?

I tried using "msg.ui_control.ymax = msg.payload + 10" but did not work.

I have been searching throughout the internet but have not found anything specific.


Put a debug on it and make sure its a number would be a good start :slight_smile:

Thanks. It is indeed! Chart is working fine. I just need a bit of a buffer. I'd like the height of the chart be dependent on a combination of the reading + 10 (this is the buffer)

msg.payload = msg.ui_control.ymax+10

give that a whirl

This was helpful. I have tried implementing it but something odd happened. So the Ymin works as expected, the reading was 25 and I set the Ymin to (reading - 5) and it set the Ymin as 20. Perfect.

However, the Ymax does something strange. When I do the same, for some odd reason, NR add the number to the end of the reading, i.e. if I have 25 + 1, NR renders this as 251! See screenshots.

Any thoughts?

The flow:
Screenshot 2021-06-13 at 09.15.02

The function that leads to the chart:

The chart at the moment
Screenshot 2021-06-13 at 09.38.31

then as leftymuller hinted your msg.payload is probably a string "25" not a numeric 25... so "25" +1 is concatenated to "251".... One of the joys of Javascript. Use parseFloat to try to make it a number

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