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. How to add text in chartview in Qml
Forum Updated to NodeBB v4.3 + New Features

How to add text in chartview in Qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 1.1k 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.
  • L Offline
    L Offline
    Lucky93
    wrote on last edited by
    #1

    I need to have customized label for x and y axis in chartview in QMl.How can i add the text inside chartview

    1 Reply Last reply
    0
    • ashajgA Offline
      ashajgA Offline
      ashajg
      wrote on last edited by
      #2

      hi @Lucky93 if i got your problem you want to denote x and y axis with some name....

      here is a small example:

      import QtQuick 2.9
      import QtQuick 2.0
      import QtCharts 2.0
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          color:"black"
      Rectangle{
      
          width:300
          height:300
          color:"black"
              ChartView {
                  backgroundColor: "black"
                  height: 30
                  width:30
                  title: "Spline"
                  anchors.fill: parent
                  antialiasing: true
                  ValueAxis {
                      id: xAxis
                    titleText: "humidity"
                      min: 0
                      max: 10
                  }
                  ValueAxis {
                      id: yAxis
                      min: 0
                      max: 10
                       titleText: "tempreature"
                  }
                  SplineSeries {
                      name: "SplineSeries"
                      axisX:xAxis
                      axisY:yAxis
      
                      XYPoint { x: 0; y: 0.0 }
                      XYPoint { x: 1.1; y: 3.2 }
                      XYPoint { x: 1.9; y: 2.4 }
                      XYPoint { x: 2.1; y: 2.1 }
                      XYPoint { x: 2.9; y: 2.6 }
                      XYPoint { x: 3.4; y: 2.3 }
                      XYPoint { x: 4.1; y: 3.1 }
                  }
              }
      }
          }
      

      here I am using titleText: "humidity" and titleText: "tempreature" to add text to my axis

      ValueAxis {
                      id: xAxis
                    titleText: "humidity"
                      min: 0
                      max: 10
                  }
                  ValueAxis {
                      id: yAxis
                      min: 0
                      max: 10
                       titleText: "tempreature"
                  }
      

      Result:

      0_1549518900556_53f3595a-f8f7-4dee-8c7e-a86f604e62b8-image.png

      here you can see humidity and tempreature is added..

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Lucky93
        wrote on last edited by
        #3

        not the title of the x and y axis ,
        i need to add text inside the chartview grid ,relative to x and y of the axis

        ashajgA 1 Reply Last reply
        0
        • L Lucky93

          not the title of the x and y axis ,
          i need to add text inside the chartview grid ,relative to x and y of the axis

          ashajgA Offline
          ashajgA Offline
          ashajg
          wrote on last edited by
          #4

          @Lucky93
          as you said relative to x and y axis...
          something like this

          0_1549522464140_1152c4a5-7560-4bfe-8982-add3a86db40d-image.png

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Lucky93
            wrote on last edited by
            #5

            no not associated to the spline series,
            for example i need to have some random text above the wave like " current data plotted below"

            1 Reply Last reply
            0
            • ashajgA Offline
              ashajgA Offline
              ashajg
              wrote on last edited by
              #6

              ok.
              I ll try to find some way if I got something I ll let you know...

              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