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 clear old point using qt charts when end of plot is reached?
Qt 6.11 is out! See what's new in the release blog

How to clear old point using qt charts when end of plot is reached?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 505 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.
  • T Offline
    T Offline
    Tom44
    wrote on last edited by
    #1

    Hi

    I am using line series to plot points. when wave reaches at the end of plot
    I want to clear the oldest point and plot a new point from the start of the plot.

    code:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtCharts 2.0
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        property var i: 0
        property var j: 0
        property var k: 0
        
        ChartView {
            title: "Line"
            anchors.fill: parent
            antialiasing: true
            ValueAxis {
                id: xAxis
                min: 0
                max: 10;
            }
            
            ValueAxis {
                id: yAxis
                min: 0
                max: 10
            }
            
            LineSeries {
                id: lineSer
                name: "LineSeries"
                axisX:  xAxis
                axisY:yAxis
            }
        }
        Timer {
            interval: 500; running: true; repeat: true
            onTriggered: {
                i = i + 0.5
                if(i > 10)
                {
                    i = 0
                    j = 1
                    k=k+1
                    
                }
                if(j===1)
                {
                    
                    lineSer.remove(0)
                }
                
                lineSer.append(i,k)
                
            }
            
        }
    }
    

    Screenshot 2020-01-13 at 3.36.12 PM.png

    I am able to clear the point but there is a line drawn from 10.0 to 0.0(digonal) probably due to append. So how can I eliminate this line as it is not needed?

    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