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. why extra lines appear here by QCharts
QtWS25 Last Chance

why extra lines appear here by QCharts

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 4 Posters 948 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 Offline
    M Offline
    mchinand
    wrote on last edited by
    #4

    What if you exclude the number->QString formatting->number step when you are appending your points. Do you still get these artifacts?

    M 1 Reply Last reply
    0
    • M mchinand

      What if you exclude the number->QString formatting->number step when you are appending your points. Do you still get these artifacts?

      M Offline
      M Offline
      mr.five
      wrote on last edited by
      #5

      @mchinand thank you ,i know that is not a good method to do so , but i need the required precision ,so have any other better method to take place? in the other hand, i have exclude that ,but there is still have the extra line on the graph , alas~~~

      M JonBJ 2 Replies Last reply
      0
      • M mr.five

        @mchinand thank you ,i know that is not a good method to do so , but i need the required precision ,so have any other better method to take place? in the other hand, i have exclude that ,but there is still have the extra line on the graph , alas~~~

        M Offline
        M Offline
        mchinand
        wrote on last edited by
        #6

        I think the preferred way to do that formatting (format to two decimal places) is:

        QString::number(hstTodayClose[index-1]/100.00, 'f', 2).toDouble();

        There's nothing weird with your indexing of time[] with i and hstTodayClose[] with index? This depends on how those arrays are populated, so could be correct.

        M 1 Reply Last reply
        0
        • M Offline
          M Offline
          mchinand
          wrote on last edited by
          #7

          Also, where is points defined and initialized? Perhaps try clearing that at the start of addData()

          1 Reply Last reply
          1
          • M mchinand

            I think the preferred way to do that formatting (format to two decimal places) is:

            QString::number(hstTodayClose[index-1]/100.00, 'f', 2).toDouble();

            There's nothing weird with your indexing of time[] with i and hstTodayClose[] with index? This depends on how those arrays are populated, so could be correct.

            M Offline
            M Offline
            mr.five
            wrote on last edited by
            #8

            @mchinand ```
            QString::number(hstTodayClose[index-1]/100.00, 'f', 2).toDouble();

            this method i have used, but  it  loss precision when i debug out the number.    the points was initialized like this:```
            QList<QPointF> points={};
            

            and i tried to add points.clear() ,but it seems like have no help on the grap ,the extra lines are still there.

            1 Reply Last reply
            0
            • M mr.five

              @mchinand thank you ,i know that is not a good method to do so , but i need the required precision ,so have any other better method to take place? in the other hand, i have exclude that ,but there is still have the extra line on the graph , alas~~~

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #9

              @mr-five

              • Check @mchinand's comment: if points is not empty (left over from before?) you would "jump back" to x == 0, could make it look screwy.
              • Verify how it looks using just all points as QPointF(index, index) instead. Should be diagonal line. Any artefacts?
              • Verify the length of hstTodayClose, is [index-1] always within bounds?
              • Binary chop the number of points you plot, do the artefacts still appear? Keep chopping in half.
              • To pass a floating point number of 2 decimal places you shouldn't need to convert to a string and then back to a number. Something like int(num * 100 + 0.5) / 100.0 should work.
              M 1 Reply Last reply
              1
              • JonBJ JonB

                @mr-five

                • Check @mchinand's comment: if points is not empty (left over from before?) you would "jump back" to x == 0, could make it look screwy.
                • Verify how it looks using just all points as QPointF(index, index) instead. Should be diagonal line. Any artefacts?
                • Verify the length of hstTodayClose, is [index-1] always within bounds?
                • Binary chop the number of points you plot, do the artefacts still appear? Keep chopping in half.
                • To pass a floating point number of 2 decimal places you shouldn't need to convert to a string and then back to a number. Something like int(num * 100 + 0.5) / 100.0 should work.
                M Offline
                M Offline
                mr.five
                wrote on last edited by
                #10

                @JonB thank you.

                1. the points is empty when i used points.clear() before add data, but it is not works
                  2.it is not diagonal line, like this ,and i do not know why?
                  dcf61569-20b4-4d73-8a82-42b0e5a8761a-image.png ![alt text](image url)
                  1c7234e4-74b3-4ed7-90cc-efef1d206239-image.png
                JonBJ 1 Reply Last reply
                0
                • M mr.five

                  @JonB thank you.

                  1. the points is empty when i used points.clear() before add data, but it is not works
                    2.it is not diagonal line, like this ,and i do not know why?
                    dcf61569-20b4-4d73-8a82-42b0e5a8761a-image.png ![alt text](image url)
                    1c7234e4-74b3-4ed7-90cc-efef1d206239-image.png
                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #11

                  @mr-five
                  Looks like two separate diagonal lines. Does your x value change from positive to negative?? What is the range of your index variable? Make it int index instead of qreal, any difference? Only print the first 50% of all the points, do you then get just the left-hand line?

                  M 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @mr-five
                    Looks like two separate diagonal lines. Does your x value change from positive to negative?? What is the range of your index variable? Make it int index instead of qreal, any difference? Only print the first 50% of all the points, do you then get just the left-hand line?

                    M Offline
                    M Offline
                    mr.five
                    wrote on last edited by mr.five
                    #12

                    @JonB
                    e387ec4d-4ae8-4c79-9890-5150510b8014-image.png
                    f63cadb8-77b8-4e76-8441-1bb04f3233e2-image.png

                    i found one probable cause is that i forgot to initialize the range of the Y axis, and after i do so:

                    ui->fenshiLineChart->chart()->axes(Qt::Vertical).at(0)->setRange(todayLow[itemNum-1],todayHigh[itemNum-1]);
                    

                    the graph only leave one extra line like this,and i do not know the reason again,thank you

                    JonBJ 1 Reply Last reply
                    0
                    • M mr.five

                      @JonB
                      e387ec4d-4ae8-4c79-9890-5150510b8014-image.png
                      f63cadb8-77b8-4e76-8441-1bb04f3233e2-image.png

                      i found one probable cause is that i forgot to initialize the range of the Y axis, and after i do so:

                      ui->fenshiLineChart->chart()->axes(Qt::Vertical).at(0)->setRange(todayLow[itemNum-1],todayHigh[itemNum-1]);
                      

                      the graph only leave one extra line like this,and i do not know the reason again,thank you

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #13

                      @mr-five
                      It looks like that would be produced if you somehow have an extra (0, 0) at the end of the series?

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mr.five
                        wrote on last edited by
                        #14

                        @JonB @JoeCFD @mchinand thank you all! i have found the reason,the axis count not suit my series count,if some missed ,there will have extra lines

                        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