QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgshistogram.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshistogram.h
3 --------------
4 begin : May 2015
5 copyright : (C) 2015 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSHISTOGRAM_H
19#define QGSHISTOGRAM_H
20
21#include "qgis_core.h"
22#include "qgsfeedback.h"
23
24#include <QList>
25
26class QgsVectorLayer;
27
28
35
36class CORE_EXPORT QgsHistogram
37{
38 public:
39
40 QgsHistogram() = default;
41
42 virtual ~QgsHistogram() = default;
43
48 void setValues( const QList<double> &values );
49
58 bool setValues( const QgsVectorLayer *layer, const QString &fieldOrExpression, QgsFeedback *feedback = nullptr );
59
67 double optimalBinWidth() const;
68
77 int optimalNumberBins() const;
78
86 QList<double> binEdges( int bins ) const;
87
94 QList<int> counts( int bins ) const;
95
96 private:
97
98 QList<double> mValues;
99 double mMax = 0;
100 double mMin = 0;
101 double mIQR = 0;
102
103 void prepareValues();
104
105};
106
107#endif // QGSHISTOGRAM_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
QgsHistogram()=default
QList< int > counts(int bins) const
Returns the calculated list of the counts for the histogram bins.
int optimalNumberBins() const
Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule...
double optimalBinWidth() const
Calculates the optimal bin width using the Freedman-Diaconis rule.
QList< double > binEdges(int bins) const
Returns a list of edges for the histogram for a specified number of bins.
virtual ~QgsHistogram()=default
void setValues(const QList< double > &values)
Assigns numeric source values for the histogram.
Represents a vector layer which manages a vector based dataset.