How to maintain QChart resetZoom level after QValueAxis::setRange and/or QBarCategoryAxis::setCategories
-
Hello, I'm trying to make a
QCandlestickSeries
that updates aQChart
in real-time. I've gotten to the point where everything works, but one feature. Whenever I add the new data, which updates values correctly, I append aQString
representing aQDateTime
for theQBarCategoryAxis::setCategories
call to update my x-Axis of dates. I also update the range of the y-Axis which is aQValueAxis
by callingQValueAxis::setRange
. If I call either of these functions, I looked in to the source code of theQChartPrivate
stuff and it appears that they both make calls toQChart::zoomReset()
. There is no ability to get the current zoom factor's value, nor does Qt seem to even hold on to it in its Private implementation ofQChart
. I'd really like to have the effect where I can save the current settings for myQChartPrivate's m_presenter
member variable and restore the state such that when I add new data and set new ranges, I can put the presenter back to its original zoom and scroll location. Is there anyway for me to do this with the public interface without editing Qt source code? I essentially just need a boolean that flips whether I want to preserve my zoom and center upon new ranges, but there doesn't seem a possible way to do this without "hacking" the chart to zoom back to its previous value, which I'm having a hard time doing with aQBarCategoryAxis
since the min and max aren't pixel values on the chart, but rather just of typeQString
. -
I made a mistake in understanding the what
QBarCategoryAxis::setCategories
did. So to fix my issue, I only callQBarCategoryAxis::setCategories
on startup when I seed some historical data and after that I only callQBarCategoryAxis::append
for real-time updates fed to the program. The call toQBarCategoryAxis::append
does not set the range without the user's permission, so this is the behavior I wanted. I also only need to callQValueAxis::setRange
on startup, otherwise I don't want to call it again. Now it exhibits the desired behavior.