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. QChart Range / TickCount Question

QChart Range / TickCount Question

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 218 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    Rich Bair
    wrote last edited by Rich Bair
    #1

    I have a report from the field on 5.12.x on a chart.

    I have the following code with a file with maxTime = 106.4 and printerTimeScale = 0 (1min blocks).

                // *** Chart Area ***
                int numBlocks = 0;
                switch(printerTimeScale) {
                default:
                case 0:
                    numBlocks = static_cast<int>(maxTime) + 1;
                    break;
                case 1:
                    numBlocks = static_cast<int>(maxTime/2.0 + (static_cast<int>(maxTime) % 2) + 1);
                    break;
                case 2:
                    numBlocks = static_cast<int>(maxTime/5.0 + (static_cast<int>(maxTime) % 5) + 1);
                    break;
                }
    
                reinterpret_cast<QValueAxis*>(chart.axes()[0])->setTickCount(numBlocks + 1);
                reinterpret_cast<QValueAxis*>(chart.axes()[0])->setRange(0.0, numBlocks*((printerTimeScale == 0) ? 1.0 : (printerTimeScale == 1) ? 2.0 : 5.0));
    

    The data ends at 106.4 minutes as expected and the last column #107 runs from 107.0 to 108.0.
    Acrobat_JuNRXZEbgQ.png

    All good so far. However, if I go to day column #40 it runs from 39.4 to 40.4...why?
    Acrobat_iJOOs90zlN.png

    Where is this decimal coming from?

    Thanks,
    -Rich

    Joe von HabsburgJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      Can you compare that behaviour to a more recent version of Qt ? At least 5.15.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rich Bair
        wrote last edited by
        #3

        On windows I cannot replicate using 6.10.2. I'm trying to get 5.12 installed on this same system to see if that's related.

        1 Reply Last reply
        0
        • R Rich Bair

          I have a report from the field on 5.12.x on a chart.

          I have the following code with a file with maxTime = 106.4 and printerTimeScale = 0 (1min blocks).

                      // *** Chart Area ***
                      int numBlocks = 0;
                      switch(printerTimeScale) {
                      default:
                      case 0:
                          numBlocks = static_cast<int>(maxTime) + 1;
                          break;
                      case 1:
                          numBlocks = static_cast<int>(maxTime/2.0 + (static_cast<int>(maxTime) % 2) + 1);
                          break;
                      case 2:
                          numBlocks = static_cast<int>(maxTime/5.0 + (static_cast<int>(maxTime) % 5) + 1);
                          break;
                      }
          
                      reinterpret_cast<QValueAxis*>(chart.axes()[0])->setTickCount(numBlocks + 1);
                      reinterpret_cast<QValueAxis*>(chart.axes()[0])->setRange(0.0, numBlocks*((printerTimeScale == 0) ? 1.0 : (printerTimeScale == 1) ? 2.0 : 5.0));
          

          The data ends at 106.4 minutes as expected and the last column #107 runs from 107.0 to 108.0.
          Acrobat_JuNRXZEbgQ.png

          All good so far. However, if I go to day column #40 it runs from 39.4 to 40.4...why?
          Acrobat_iJOOs90zlN.png

          Where is this decimal coming from?

          Thanks,
          -Rich

          Joe von HabsburgJ Offline
          Joe von HabsburgJ Offline
          Joe von Habsburg
          wrote last edited by
          #4

          @Rich-Bair said in QChart Range / TickCount Question:

          107.0 to 108.0.

          Maybe, it's about

          void QValueAxis::setRange(qreal min, qreal max)
          setTickInterval(qreal insterval)
          

          or you can check with these

          void QValueAxis::minChanged(qreal min)
          void QValueAxis::maxChanged(qreal max)
          tickIntervalChanged(qreal interval)
          

          Because your code its calculate true.

          int getNum(int printerTimeScale, double maxTime){
              int numBlocks = 0;
              switch(printerTimeScale) {
              default:
              case 0:
                  numBlocks = static_cast<int>(maxTime) + 1;
                  break;
              case 1:
                  numBlocks = static_cast<int>(maxTime/2.0 + (static_cast<int>(maxTime) % 2) + 1);
                  break;
              case 2:
                  numBlocks = static_cast<int>(maxTime/5.0 + (static_cast<int>(maxTime) % 5) + 1);
                  break;
              }
              return numBlocks;
          }
          
              double maxTime = 106.4;
              qDebug() << "getNum 0" << getNum(0, maxTime); //getNum 0 107
              qDebug() << "getNum 1" << getNum(1, maxTime); //getNum 1 54
              qDebug() << "getNum 2" << getNum(2, maxTime); //getNum 2 23
          
              maxTime = 39.4;
              qDebug() << "getNum 0" << getNum(0, maxTime); //getNum 0 40
              qDebug() << "getNum 1" << getNum(1, maxTime); //getNum 1 21
              qDebug() << "getNum 2" << getNum(2, maxTime); //getNum 2 12
          
          
          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rich Bair
            wrote last edited by
            #5

            I tested on windows 5.12.12 and 6.10.2...no joy. The only way I can make the symptom appear is if I do something like change the range with the multiplier:

                        int numBlocks = 0;
                        switch(printerTimeScale) {
                        default:
                        case 0:
                            numBlocks = static_cast<int>(maxTime) + 1;
                            break;
                        case 1:
                            numBlocks = static_cast<int>(maxTime/2.0 + (static_cast<int>(maxTime) % 2) + 1);
                            break;
                        case 2:
                            numBlocks = static_cast<int>(maxTime/5.0 + (static_cast<int>(maxTime) % 5) + 1);
                            break;
                        }
            
                        reinterpret_cast<QValueAxis*>(chart.axes()[0])->setTickCount(numBlocks + 1);
                        reinterpret_cast<QValueAxis*>(chart.axes()[0])->setRange(0.0, numBlocks*((printerTimeScale == 0) ? **1.01** : (printerTimeScale == 1) ? 2.0 : 5.0));
            
            1 Reply Last reply
            0
            • Joe von HabsburgJ Offline
              Joe von HabsburgJ Offline
              Joe von Habsburg
              wrote last edited by
              #6

              How much does it affect you if the graph's boundaries grow by one unit? If the graph is drawn correctly, there shouldn't be a problem.

              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