How to Y-zoom a chart respecting current scrolled Y position


What MCU/Processor/Board and compiler are you using?

ESP32-S3, Arduino

What LVGL version are you using?


What do you want to achieve?

I want to zoom the chart in Y axis, using the current scrolled Y position as the centre of the zoom

Here’s a mockup:

What have you tried so far?

I have:
lv_obj_get_scroll_y() value, lv_obj_get_scroll_top(), lv_obj_get_scroll_bottom() values
and the zoom value from a slider.
But trying to figure out the math and how they are related is breaking my brain.

At the moment, I have this but it flicks the chart to the middle and zooms into the middle, losing focus of the series:

lv_obj_scroll_to_y(ui_Chart2, (lv_obj_get_scroll_bottom(ui_Chart2) + lv_obj_get_scroll_top(ui_Chart2)) / 2, LV_ANIM_OFF)

Does anyone have a code snippet I can try to understand, or an explanation?
With changing zoom - the top, bottom and current scroll Y values all change and I can’t understand how they are related and how to calculate the currently visible Y range, and therefore the zoom centre.

Bump! Anybody done this before?