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. Place text in plotting area of QML ChartView
Forum Updated to NodeBB v4.3 + New Features

Place text in plotting area of QML ChartView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 368 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.
  • Bhushan_SureB Offline
    Bhushan_SureB Offline
    Bhushan_Sure
    wrote on last edited by
    #1

    How do I place text at specific (x,y) locations within the plotting area of a QML ChartView type?
    For example, I would like to place text at the location XYPoint{x: 1.3; Y: 5.8}
    I don't want to place at window's(x,y), i want to put at plotting area's (x,y)

    I read documentation, but i don't find any property !!!!!!

    Bhushan_SureB 1 Reply Last reply
    0
    • Bhushan_SureB Bhushan_Sure

      How do I place text at specific (x,y) locations within the plotting area of a QML ChartView type?
      For example, I would like to place text at the location XYPoint{x: 1.3; Y: 5.8}
      I don't want to place at window's(x,y), i want to put at plotting area's (x,y)

      I read documentation, but i don't find any property !!!!!!

      Bhushan_SureB Offline
      Bhushan_SureB Offline
      Bhushan_Sure
      wrote on last edited by
      #2

      I got it, a simple example i am attaching for those who may need this in future

      ChartView{
          id:chart
          anchors.fill: parent
          backgroundColor: "black"
      
          LineSeries{
              id: series
              XYPoint { x: 10; y: 5  }
              XYPoint { x: 10; y: 1 }
              XYPoint { x: 15; y: 5 }
              XYPoint { x: 20; y: 10 }
              XYPoint { x: 25; y: 5 }
              XYPoint { x: 30; y: 20 }
              XYPoint { x: 40; y: 10 }
          }
      
          Text {
              id: txt
              text: "Hello"
              color: "white"
          }
      
          onWidthChanged: updatePointPosition();
          onHeightChanged: updatePointPosition();
      
          function updatePointPosition()
          {
              var p = chart.mapToPosition(series.at(3), series);
              txt.x = p.x;
              txt.y = p.y;
          }
      }
      
      1 Reply Last reply
      2

      • Login

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