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. How can I adapt my chart size according to my datas?
QtWS25 Last Chance

How can I adapt my chart size according to my datas?

Scheduled Pinned Locked Moved Unsolved General and Desktop
chartui designqt 5.4
5 Posts 2 Posters 1.1k 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.
  • D Offline
    D Offline
    deleted286
    wrote on 6 Jan 2021, 14:16 last edited by deleted286 1 Jun 2021, 14:17
    #1

    I have a scrolling dynamic chart. When the new data come, i cannot see because the chart size. Can i automatize it ? Does qt charts have a property like that?

    QChart *chart = new QChart();
     chart->addSeries(series);
     qDebug()<< series;
     QPen green(Qt::red);
     green.setWidth(2);
     series->setPen(green);
     chart->legend()->hide();
     chart->setTitle("deneme");
     chart->setAnimationOptions(QChart::AllAnimations);
    
    
    
    
     QValueAxis *axisX=new QValueAxis;
     axisX->setTickCount(10);
     chart->addAxis(axisX, Qt::AlignBottom);
     series->attachAxis(axisX);
    
     QValueAxis *axisY = new QValueAxis;
     axisY->setTickCount(5);
     chart->addAxis(axisY, Qt::AlignLeft);
     series->attachAxis(axisY);
    
     QChartView *chartView = new QChartView(chart);
     chartView->setRenderHint(QPainter::Antialiasing);
    
     this->setCentralWidget(chartView);
    

    Ekran görüntüsü 2021-01-06 171507.png

    There are datas on the right but we cannot see

    P 1 Reply Last reply 6 Jan 2021, 16:44
    0
    • D deleted286
      6 Jan 2021, 14:16

      I have a scrolling dynamic chart. When the new data come, i cannot see because the chart size. Can i automatize it ? Does qt charts have a property like that?

      QChart *chart = new QChart();
       chart->addSeries(series);
       qDebug()<< series;
       QPen green(Qt::red);
       green.setWidth(2);
       series->setPen(green);
       chart->legend()->hide();
       chart->setTitle("deneme");
       chart->setAnimationOptions(QChart::AllAnimations);
      
      
      
      
       QValueAxis *axisX=new QValueAxis;
       axisX->setTickCount(10);
       chart->addAxis(axisX, Qt::AlignBottom);
       series->attachAxis(axisX);
      
       QValueAxis *axisY = new QValueAxis;
       axisY->setTickCount(5);
       chart->addAxis(axisY, Qt::AlignLeft);
       series->attachAxis(axisY);
      
       QChartView *chartView = new QChartView(chart);
       chartView->setRenderHint(QPainter::Antialiasing);
      
       this->setCentralWidget(chartView);
      

      Ekran görüntüsü 2021-01-06 171507.png

      There are datas on the right but we cannot see

      P Online
      P Online
      Pl45m4
      wrote on 6 Jan 2021, 16:44 last edited by
      #2

      @suslucoder

      Set the range of your X-Axis so that your line series fits in completely

      https://doc.qt.io/qt-5/qvalueaxis.html#setRange


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      D 1 Reply Last reply 7 Jan 2021, 05:51
      2
      • P Pl45m4
        6 Jan 2021, 16:44

        @suslucoder

        Set the range of your X-Axis so that your line series fits in completely

        https://doc.qt.io/qt-5/qvalueaxis.html#setRange

        D Offline
        D Offline
        deleted286
        wrote on 7 Jan 2021, 05:51 last edited by
        #3

        @Pl45m4 Can we do it automatically?

        P 1 Reply Last reply 7 Jan 2021, 15:16
        0
        • D deleted286
          7 Jan 2021, 05:51

          @Pl45m4 Can we do it automatically?

          P Online
          P Online
          Pl45m4
          wrote on 7 Jan 2021, 15:16 last edited by
          #4

          @suslucoder

          I don't know... Can you?! It's your project :)
          You know best where you add new data and where you can insert the code to rearrange your axis.

          Maybe this helps:

          • https://doc.qt.io/qt-5/qxyseries.html#pointAdded

          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          D 1 Reply Last reply 8 Jan 2021, 10:28
          0
          • P Pl45m4
            7 Jan 2021, 15:16

            @suslucoder

            I don't know... Can you?! It's your project :)
            You know best where you add new data and where you can insert the code to rearrange your axis.

            Maybe this helps:

            • https://doc.qt.io/qt-5/qxyseries.html#pointAdded
            D Offline
            D Offline
            deleted286
            wrote on 8 Jan 2021, 10:28 last edited by
            #5

            @Pl45m4 Thank you

            1 Reply Last reply
            0

            1/5

            6 Jan 2021, 14:16

            • Login

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