QCustomPlot Discussion and Comments

Resampling plotted data points based on zoom level.Return to overview

Hi,

I currently use QCPGraph to plot in realtime data from different measurment instruments (I get one data point every 100ms). It works great.
I also need to be able to see the historical data for up to 8 hours, which mean I have a big zoom range (let's say for 1x to 1000X) on the yAxis that I use as key axis (time is the key)

My problem is if I zoom out a lot, the graph become fuzzy and unreadable because the number of points to draw is way to big.
I was wondering if there was a built-in mecanism to resample the datapoints to be plotted based on the zoom level ?

Do you have any suggestion to implement such a feature ?

EDIT: it would appears I was completely wrong on my diagnosis.

So I've found the setAdaptiveSampling() method in the QCPGraph class.

I though it would solve all my problems but it seems to be be enabled by default, so I disabled it on one graph to see the difference, and it seems the adaptive sampling is actually causing my troubles.

here is a link to a screen shot that illustrate the graphical artifact. The 2 QCPGraphs are plots of the same dataset with a constant offset in the values to be able to visualize the 2 graphs side by side.
http://imageshack.com/a/img912/9067/XqnqRl.jpg

I believe that this is not the intended behavior for the adaptive sampling, and that I have found a bug or a corner case in the adaptive sampling algo.
I am using yAxis as my key axis and xAxis as my value axis.
I think that might be part of the problem.

I also tried to disable anti-aliasing but it doesn't seem to have any effect.

I'll be reviewing the adaptive sampling algo now.
updates to come.

Hi, Interesting find.

Could you send me the code that causes that behaviour via email (see contact page)?

I will provide you with a working example to repoduce the behavior as soon as possible.

Thanks for spotting that bug. Here's the fix:

In the amalgamated sources, at line 15670-15671 (version 1.2.1), replace the lines

      int reversedFactor = keyAxis->rangeReversed() ? -1 : 1; // is used to calculate keyEpsilon pixel into the correct direction
      int reversedRound = keyAxis->rangeReversed() ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey

with

      int reversedFactor = keyAxis->rangeReversed() != (keyAxis->orientation()==Qt::Vertical) ? -1 : 1; // is used to calculate keyEpsilon pixel into the correct direction
      int reversedRound = keyAxis->rangeReversed() != (keyAxis->orientation()==Qt::Vertical) ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey

This fix will be in the upcoming 1.3.0 release.

Nice fix. Works great.

Thank you and props on your amazing support !
Bug report to fix in 5 hours, that is so serious reactivity !

looking forward to 1.3.0.