Yes, you can use the update method there.
Just by looking at your yAxis config, everything seems to be fine, but I can't do much without looking at how the temp variable is created.
If you need further assistance in that matter, please recreate that issue in an online editor so I can take a look at it.
In the meantime, please study the xAxis.max API Reference to get a better understanding of how it is calculated in different scenarios.
API Reference: https://api.highcharts.com/highcharts/yAxis.max
Regards!