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. Qt Chart is not updated after updating the series
QtWS25 Last Chance

Qt Chart is not updated after updating the series

Scheduled Pinned Locked Moved Solved General and Desktop
charts
12 Posts 3 Posters 12.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.
  • M MrShawn

    Try attaching your axis to the series. Does that fix anything?

    M Offline
    M Offline
    milan
    wrote on last edited by
    #3

    @MrShawn . No it didnt help.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MrShawn
      wrote on last edited by
      #4

      I don't see the new point out of bounds of your axis so that is good. From what I understand when appending the series you should be good as long as it is the pointer to the correct series. Assuming the discrepancy for scatter series and line series is an artifact of you swapping between line and scatter series for troubleshooting, are you constantly running something without allowing the event handler to process? Try adding QApplication::processEvents(); after your repaint.

      M 1 Reply Last reply
      0
      • M MrShawn

        I don't see the new point out of bounds of your axis so that is good. From what I understand when appending the series you should be good as long as it is the pointer to the correct series. Assuming the discrepancy for scatter series and line series is an artifact of you swapping between line and scatter series for troubleshooting, are you constantly running something without allowing the event handler to process? Try adding QApplication::processEvents(); after your repaint.

        M Offline
        M Offline
        milan
        wrote on last edited by
        #5

        @MrShawn . I added QApplication::processEvents(); , but it also did not help.
        I do have other background functions working. But what I do not understand is why the charts is not updated despite the series have updated with new data points.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MrShawn
          wrote on last edited by
          #6

          Are you sure you are sending it a pointer to the correct series? You are appending your line series but you are attaching a scatter series.

          M 1 Reply Last reply
          1
          • M MrShawn

            Are you sure you are sending it a pointer to the correct series? You are appending your line series but you are attaching a scatter series.

            M Offline
            M Offline
            milan
            wrote on last edited by
            #7

            @MrShawn. I was switching line and scatter series. But this is not the cause of the problem. I do correctly added same series and appended the same series. I will edit the posted code.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MrShawn
              wrote on last edited by
              #8

              I trust you I was just making sure. I really can't think of anything else given what I see from your code.

              M 1 Reply Last reply
              0
              • M MrShawn

                I trust you I was just making sure. I really can't think of anything else given what I see from your code.

                M Offline
                M Offline
                milan
                wrote on last edited by
                #9

                @MrShawn . You are right, you once suggested. Maybe the only updating the series did not update the pointer .I am not sure thought. But his fixed the problem. Every time I update the series, I have to remove the series and again add the series. I do not understand why is like this.

                        chart->removeSeries(scatterseries);
                        chart->addSeries(scatterseries);
                
                1 Reply Last reply
                3
                • M Offline
                  M Offline
                  MrShawn
                  wrote on last edited by
                  #10

                  I think on my first code I wrote for Charts I did a similar thing. As I got used to QCharts and how things were working I stopped doing that. Looking back at some code I do recently, where I pull data from DB and populate the series from that data. I can confirm that you should not have to do that. That is why my suspicion is that the series you were appending is not truly on the chart, and by adding that code it does now actually add it.

                  Anyways if it works it works.

                  M 1 Reply Last reply
                  0
                  • M MrShawn

                    I think on my first code I wrote for Charts I did a similar thing. As I got used to QCharts and how things were working I stopped doing that. Looking back at some code I do recently, where I pull data from DB and populate the series from that data. I can confirm that you should not have to do that. That is why my suspicion is that the series you were appending is not truly on the chart, and by adding that code it does now actually add it.

                    Anyways if it works it works.

                    M Offline
                    M Offline
                    milan
                    wrote on last edited by
                    #11

                    @MrShawn . Yes it works now. I am wondering what could be the better way instead of removing and adding series again and again. I can think only other way to be to create new class inheriting QCharts and create series as a class member of the class.

                    1 Reply Last reply
                    0
                    • 6thC6 Offline
                      6thC6 Offline
                      6thC
                      wrote on last edited by
                      #12

                      seen https://doc.qt.io/qt-5/qxyseries.html#replace-5 ?

                      even if you are doing it just for one point - by destroying and creating a series over and over you do this anyhow. has to be quicker/better.

                      I belive that also invokes
                      https://doc.qt.io/qt-5/qxyseries.html#pointsReplaced

                      ChartView should handle redraw and everything for you.

                      1 Reply Last reply
                      0
                      • JonBJ JonB referenced this topic on

                      • Login

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