QML ChartView absolute scroll value (and zoomIn)
-
QML ChartViews have the default scroll methods such as:
https://doc.qt.io/qt-5/qml-qtcharts-chartview.html#scrollDown-method
They work by scrolling the view by some pixels to some direction. But this scroll is incremental (eg, calling
mychart.scrollDown(3)
twice will scroll by 6 pixels).Is there a way to scroll using an absolute value? (that is, scroll an amount based the initial chart position when the component was instantiated).
In other words, "reset" the scroll, that is, set the total scroll to "0", and call the
scrollDown()
from there, when no scroll had been done yet.I'm asking because when using
zoomIn()
with the chart with scroll, and then zomming out, the scroll gets messed up (i.e, it doesn't go back to the place where it was "scrolled to" previous to callingzoomIn()
) and so I would need to "reset" the scrolling somehow. I tried accumulating the "scroll amount" in a variable, but as I said, when scrolling with zoom enabled, the total scrolled amount in pixels is different for each zoom factor, and the value is ultimately wrong. -
It turns out that
zoomReset()
resets the scroll as well, so all the scrolling made while zommed in is reverted:(from the Docs) Note: This will also reset scrolling and explicit axis range settings specified between the first zoom operation and calling this method. If no zoom operation has been performed, this method does nothing.