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. QCharts automatic axes scaling problem

QCharts automatic axes scaling problem

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.0k Views 2 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.
  • S Offline
    S Offline
    SebastianH
    wrote on last edited by
    #1

    Dear all,

    I want to plot data with QCharts. My idea is to create a chart and series in the constructor and add the series to the chart. Then I'd like like to add data to the series in a function and add axes to the chart that are scaled to the data points.

    createDefaultAxes() seems to do just what I want, but the scaling only works if I add the series to the chart after adding the data points.

    My code looks like so:

        QLineSeries *series = new QLineSeries();
        QChart *chart = new QChart();
        chart->setTitle("Simple line chart example");
        ui->chartView->setChart(chart);
        ui->chartView->setRenderHint(QPainter::Antialiasing);
    
        chart->addSeries(series); // <- axes _not_ scaled properly
    
        series->append(0, 0);
        series->append(2, 4);
        series->append(3, 8);
        series->append(7, 4);
        series->append(10, 5);
    
        // chart->addSeries(series); // <- axes scaled properly
    
        chart->createDefaultAxes();
    

    0_1503392158044_QChart.png

    I don't really understand why it makes a difference, where series is added to chart. In the end, it's just a pointer, right?

    Does anyone have an idea how I can tell chart that its series has updated?

    Any help is appreciated :-)

    Best,
    Sebastian

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SebastianH
      wrote on last edited by
      #2

      Can anyone just confirm that it at least should work? Or am I reading the documentation wrong? Otherwise I'd file a bug...

      Best,
      Sebastian

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        From a quick look at the documentation, I haven't see anything stating that adding points to a series after it has been added to a chart should trigger anything. The QAstractSeries class also doesn't seem to offer anything related to triggering an update.

        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

        • Login

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