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. Auto Axes in QML Lineseries Charts

Auto Axes in QML Lineseries Charts

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 2.8k 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.
  • E Offline
    E Offline
    eswar
    wrote on last edited by eswar
    #1

    Hi

    In line series charts, i was append the c++ data to qml. Herewith add coding for your reference. In that i need to auto adjust the X and Y axes minimum and maximum value based on the received data from c++.

    ChartView {
    
        id: chartView
    
        title: "Real Time Charts"
        anchors.fill: parent
        animationOptions: ChartView.SeriesAnimations
        antialiasing: true
        theme: ChartView.ChartThemeBlueCerulean
    
        ValueAxis {
            id: axisY2
            min: 0
            max: 100
            minorTickCount: 3
            tickCount: 10
    
        }
    
        ValueAxis {
            id: axisX
            min: 0
            max: 50
            minorTickCount: 3
            tickCount: 7
            gridVisible: false
           color: "white"
        }
    
        LineSeries {
            id: lineSeries1
            name: "signal 1"
            axisX: axisX
            axisY: axisY1
    

    For rate changed, i was append the data to the lineseries...

            onRateChanged:  {
    

    lineSeries1.append(currentIndex,rate)

        }
    

    Question?

    Instead of defining X and Y min and max values, i need a solution to adjust min and max values automatically based on the received data.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SamGrant
      wrote on last edited by
      #2

      I did something similar to this, but using JavaScript to read my data...

      I have two properties in my main.qml that are my min & max for my axis. I update them via the JavaScript.

      In my QML with the charts, I make sure that the min & max parameters point to the properties in my main.qml.

      main.qml :

      property alias appWin: mainWindow
      property double maxWspd: 0.0
      property double minWspd: 100.0
      

      JavaScript:

      if( appWin.maxWspd < Math.ceil((appWin.wxWspd))+1 ) {
          appWin.maxWspd = Math.ceil((appWin.wxWspd))+1;
      }
      if( appWin.minWspd > Math.floor((appWin.wxWspd))-1 ) {
          appWin.minWspd = Math.floor((appWin.wxWspd))-1;
      }
      

      MyGraphs.qml:

              ValueAxis {
                  id: axisYw
                  min: appWin.minWspd
                  max: appWin.maxWspd
                  tickCount: 5
                  labelFormat: "%.1f"
                  labelsFont:Qt.font({pointSize: 12})
                  labelsColor: appWin.baseFontColor
                  color: appWin.graphTickColor
              }
      
      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