How to plot the large real time data in qwtplot ?
Hello,
I would like to plot the large amount of data in graph. data is near about 5 million.
1. How can I plot that data efficiently on graph?
I use below method to update the graph in real time.
******************************************
Code:
LargeDataPlot::LargeDataPlot() :d_paintedPoints(0)
{
d_directPainter = new QwtPlotDirectPainter();
setAutoReplot(false);
setCanvas(new Canvas());
}
LargeDataPlot::~LargeDataPlot()
{
d_directPainter->deleteLater();
}
{
auto curveData = d_curve->data();
const int numPoints = curveData->size();
if (numPoints > 0) {
const bool doClip = !canvas()->testAttribute(Qt::WA_PaintOnScreen);
if (doClip)
{
/*
Depending on the platform setting a clip might be an important
performance issue. F.e. for Qt Embedded this reduces the
part of the backing store that has to be copied out - maybe
to an unaccelerated frame buffer device.
*/
const QSize symbolSize
= d_curve
->symbol
()->size
();
QRect r
(0,
0, symbolSize.
width() + 2, symbolSize.
height() + 2);
QwtScaleMap::transform(xMap, yMap, curveData
->sample
(numPoints
- 1));
r.moveCenter(center.toPoint());
clipRegion += r;
d_directPainter->setClipRegion(clipRegion);
}
d_directPainter->drawSeries(d_curve,
numPoints - 1, numPoints - 1);
}
}
******************************************
2. How can Line in between two data point in curve.
******************************************
I need to some functionality from qwtPlot, which is help to first identify the curve pen color and symbol.
then I need to plot the line in between last point and second last point.
******************************************
3. How can I change the axis scale in real time?
*******************************************
If i will call replot then plot is change the axis scale according to Data value.
*******************************************
4. At few place I am using QwtPlot::replot() method of graph. such as zoom in, zoom out, reste the graph, and mouse wheel direction change.
**********************************************
is it any alternative way instead of replot because of replot is very slow whenever large amount of data is available.
**********************************************
5. if possible then I am planing to optimized the large amount of data, amd trying to make smooth curve.
**********************************************
from: http://zone.ni.com/reference/en-XX/h...rge_data_sets/
To implement max-min decimation, first determine the pixel width of the graph. Use the Plot Area:Size:Width property of the graph to find this. To reduce artifacts, you need at least two decimation intervals per pixel width, so multiply the graph pixel width by two to get the nominal number of intervals to divide the data into. Divide the data length by this number and round up to the nearest integer. This gives you the chunk size for decimation. For each chunk, find the maximum and minimum points and order them in the same order they occurred in the data set. Do not worry that the last chunk has less points than the rest. The problem is less than a pixel wide and cannot be seen on the computer screen. String all the max and min data together and plot. You will have four points per pixel width on the screen. This allows the single, pixel-wide spike to occur without bleeding over into adjacent pixels. The max/min decimation assures you always see the peaks of the data, giving you the solid band the high frequency sine wave should produce. This all occurs with much less data plotted to the graph, resulting in much higher speeds.
is it any way to change the chunk size with respect to zoom in and zoom out.
if it is Zoom out then i would like to increase the chunk size and if it is zoom in and i would like to decrease the chunk size.
in general i would like to modify value inside QwtWeedingCurveFitter::setChunkSize().
**********************************************
Any please help of or give me direction for archive functionality.
Re: How to plot the large real time data in qwtplot ?
Please split your posting into single questions and try to find a solution for them on your own first. I try to help when someone gets stuck, but I'm not going to do your job.
Regarding the min/max optimization. It is implemented in all branches >= 6.2 and can be activated by setting the QwtPlotCurve::FilterPointsAggressive ( fast algo can be done inside the update cycle ) flag.
But even with having all optimizations enabled I don't recommend to pass all 5 million points to the plot and you should do some sort of preprocessing to reduce the number of points.
Maybe overload QwtSeriesData<QPointF> and do some magic behind the scenes. F.e you can calculate different data sets according to the zoom level using QwtWeedingCurveFitter ( too slow to do it in the update cycle ! ).
Showing real time data with a certain refresh rate is a different story. But in general you should always decouple the update rate from the sample rate - drawing each point as it arrives is no good idea. There is not much sense in having a higher refresh rate than let's say 10fps - a line plot is no movie, where the complete screen gets updated with each frame.
In all branches >= 6.2 you will find a lot of spline interpolation algos implemented, while in 6.1 you only have the cubic spline algo, that is expensive and its implementation is broken. If it is only about making a curve smooth spline interpolation is a good option.
Uwe
Re: How to plot the large real time data in qwtplot ?
Thank you for your direction. I am able to improve performance after direction from you. I do have one question regarding QwtPlotCurve::minXvalue(), QwtPlotCurve::minYvalue(), QwtPlotCurve::maxXvalue(), and QwtPlotCurve::maxYvalue() funcation.
I set the filter-container (QVector) point to curve using setSamples.
curve1->setSamples(new ListSeriesData(*newData.data[QwtPlot::xBottom], *newData.data[QwtPlot::yLeft]));
- ListSeriesData classs is derived from QwtSeriesData<QPointF>;
if i will append new data in real time then it is paint on graph correctly using drawSeries().
Now whenever I will call to curve1->minXvalue(); or curve1->maxXvalue(); or curve1->maxYvalue(); or curve1->minYvalue(); then it is always return zero.
what could be the reason? why is it always return zero? Am i missing to set any things?
Added after 1 26 minutes:
I got solution i was doing mistake in setting QRectF boundingRect() const; inside the ListSeriesData class.
I was setting the QRectF rect inside the constructor of ListSeriesData class and read by boundingRect();