Results 1 to 2 of 2

Thread: The painting process of scatter series in QtCharts

  1. #1
    Join Date
    Sep 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default The painting process of scatter series in QtCharts

    I am developing an application where very large measurement data (on the order of millions of data points) must be plotted as a scatter chart. I also want to implement an additional functionality. There will be a play button and when the user clicks this button, the data points will be dynamically added to the chart. (As groups of 10000 points.) So, the user will be able to see how the data set changes over the course of time. I am using the QtCharts libraries.

    Some important points:
    1) All data points are available before drawing the chart.
    2) First, the minimum and maximum values of the data points for both coordinates is determined. The ranges of the axes are set to these values.
    3) The x coordinate values of the data points are monotonically increasing. (The x coordinate denotes the time.)
    From 2 and 3, we can see that when new data points are added to the chart, 1) the axes do not need to be rescaled, 2) the points that are currently available on the chart will not move.

    I have prepared the data set, such that the points are divided into groups of 10000, with each group being added to a different scatter series. I have set the color of the scatter series the same, so they look as if they were the same series. In each iteration of the loop, the next scatter series is added to the chart and the repaint() method of chart view is invoked.
    Qt Code:
    1. for (i = 0; i < groupCount; i++) {
    2. chart->addSeries(scatterSeries.at(i));
    3. chart->setAxisX(axisX, scatterSeries.at(i));
    4. chart->setAxisY(axisY, scatterSeries.at(i));
    5. chartView->repaint();
    6. QCoreApplication::processEvents();
    7. }
    To copy to clipboard, switch view to plain text mode 

    The replay of the data begins really fast, but then becomes very slow. I have figured out that this is because when the chart view's repaint() method is invoked, all the attached scatter series are painted once again. However, it would be enough if only the scatter series that has been attached most recently was painted. I'm still trying to figure out how to do this. I tried re-implementing the paintEvent() of the QChartView object, however that has nothing to do with the painting of the scatter series. It is just for painting the background of the chart. So at the moment, I'm just stuck.
    Any help will be greatly appreciated. Thanks in advance.
    Onat

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: The painting process of scatter series in QtCharts

    Any reason why you are using repaint() and not update()?
    Update uses optimizations, which might make is better.

    If the update() solution doesn't help, I would look into the animation option.
    I don't have experience with the QtCharts classes so I can't say for sure, but it seems you can have the chart animate the addition of the series for you.
    https://doc.qt.io/qt-5/qchart.html#AnimationOption-enum
    I assume that if you look for examples about how to animate a scatter chart you will find something useful.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Multiple colors QLineSeries in QtCharts
    By cmartinezdemorentin in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2017, 16:04
  2. qwt vs qtcharts
    By hassinoss in forum Qwt
    Replies: 1
    Last Post: 13th January 2017, 06:50
  3. scatter graph in Qt4
    By hamid ghous in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2009, 08:38
  4. Scatter graph
    By elcuco in forum Qwt
    Replies: 5
    Last Post: 27th December 2007, 11:48

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.