Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to maintain QChart resetZoom level after QValueAxis::setRange and/or QBarCategoryAxis::setCategories

How to maintain QChart resetZoom level after QValueAxis::setRange and/or QBarCategoryAxis::setCategories

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 338 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blanky
    wrote on last edited by
    #1

    Hello, I'm trying to make a QCandlestickSeries that updates a QChart 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 a QString representing a QDateTime for the QBarCategoryAxis::setCategories call to update my x-Axis of dates. I also update the range of the y-Axis which is a QValueAxis by calling QValueAxis::setRange. If I call either of these functions, I looked in to the source code of the QChartPrivate stuff and it appears that they both make calls to QChart::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 of QChart . I'd really like to have the effect where I can save the current settings for my QChartPrivate'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 a QBarCategoryAxis since the min and max aren't pixel values on the chart, but rather just of typeQString.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Blanky
      wrote on last edited by Blanky
      #2

      I made a mistake in understanding the what QBarCategoryAxis::setCategories did. So to fix my issue, I only call QBarCategoryAxis::setCategories on startup when I seed some historical data and after that I only call QBarCategoryAxis::append for real-time updates fed to the program. The call to QBarCategoryAxis::append does not set the range without the user's permission, so this is the behavior I wanted. I also only need to call QValueAxis::setRange on startup, otherwise I don't want to call it again. Now it exhibits the desired behavior.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved