How to maintain QChart resetZoom level after QValueAxis::setRange and/or QBarCategoryAxis::setCategories
-
Hello, I'm trying to make a
QCandlestickSeriesthat updates aQChartin 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 aQStringrepresenting aQDateTimefor theQBarCategoryAxis::setCategoriescall to update my x-Axis of dates. I also update the range of the y-Axis which is aQValueAxisby callingQValueAxis::setRange. If I call either of these functions, I looked in to the source code of theQChartPrivatestuff 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_presentermember 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 aQBarCategoryAxissince 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::setCategoriesdid. So to fix my issue, I only callQBarCategoryAxis::setCategorieson startup when I seed some historical data and after that I only callQBarCategoryAxis::appendfor real-time updates fed to the program. The call toQBarCategoryAxis::appenddoes not set the range without the user's permission, so this is the behavior I wanted. I also only need to callQValueAxis::setRangeon startup, otherwise I don't want to call it again. Now it exhibits the desired behavior.