Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ValueAxis QML Type, Y axis Auto Fit!!
Qt 6.11 is out! See what's new in the release blog

ValueAxis QML Type, Y axis Auto Fit!!

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 4 Posters 3.1k Views 3 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I had a dynamic chart now! with QML

    But how to make the ValueAxis (for y axis) to automatically fit the the plotted data through ChartView!

    I tried to get the chart data and store it in an array, then check the max and min inside the array, but it looks complicated for me and I can't even look inside the array!

    Any advice!

    1 Reply Last reply
    0
    • SeeLookS Offline
      SeeLookS Offline
      SeeLook
      wrote on last edited by
      #2

      Hi,

      Probably You may use scale prop for it.
      Just track lowest and highest values as they come in real time and when a span between them changes - adjust the scale.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kumarv
        wrote on last edited by
        #3

        Check the solution given in the following link
        https://stackoverflow.com/questions/44940190/qtcharts-auto-range-for-y-axis
        P.S. Chart is created using Cpp.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          neda
          wrote on last edited by
          #4

          Hi,
          Why don't you use the following example?
          https://forum.qt.io/topic/77439/can-someone-provide-a-working-example-of-vxymodelmapper-with-lineseries-chart/2

          void ChartModel::appendData(double const xVal,double const yVal)
          {
              setXMin(qMin(m_xMin, xVal));
              setXMax(qMax(m_xMax, xVal));
              setYMin(qMin(m_yMin, yVal));
              setYMax(qMax(m_yMax, yVal));
              int const vecSize = vecChartPoints.size();
              beginInsertRows(QModelIndex (), vecSize, vecSize);
              vecChartPoints.append(qMakePair<double, double>(xVal, yVal));
              endInsertRows();
          }
          
          ValueAxis {
                                      id: valueAxisY
                                      min: chartModel.yMin
                                      max: chartModel.yMax
                                      labelFormat: "%.2f"
                                  }
          
          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