-
- startMax = (len - (int)((plotRect.right() - plotRect.left() - 40) / GraphPixelsPerPoint));
- if(startMax < 0) {
- startMax = 0;
- }
- if(GraphStart > startMax) {
- GraphStart = startMax;
- }
- if (GraphStart > len) return;
- int vMin = INT_MAX, vMax = INT_MIN, vMean = 0, v = 0, absVMax = 0;
- int sample_index = GraphStart ;
- for( ; sample_index < len && xCoordOf(sample_index,plotRect) < plotRect.right() ; sample_index++) {
-
- v = buffer[sample_index];
- if(v < vMin) vMin = v;
- if(v > vMax) vMax = v;
- vMean += v;
- }
-
- vMean /= (sample_index - GraphStart);
-
- if(fabs( (double) vMin) > absVMax) absVMax = (int)fabs( (double) vMin);
- if(fabs( (double) vMax) > absVMax) absVMax = (int)fabs( (double) vMax);
- absVMax = (int)(absVMax*1.25 + 1);
- // number of points that will be plotted
- int span = (int)((plotRect.right() - plotRect.left()) / GraphPixelsPerPoint);
- // one label every 100 pixels, let us say
- int labels = (plotRect.right() - plotRect.left() - 40) / 100;
- if(labels <= 0) labels = 1;
- int pointsPerLabel = span / labels;
- if(pointsPerLabel <= 0) pointsPerLabel = 1;
-
+ int vMin = INT_MAX, vMax = INT_MIN, vMean = 0, v = 0, i = 0;