QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
Public Member Functions | List of all members
QgsHistogram Class Reference

Calculator for a numeric histogram from a list of values. More...

#include <qgshistogram.h>

Public Member Functions

 QgsHistogram ()
 
virtual ~QgsHistogram ()
 
QList< double > binEdges (int bins) const
 Returns a list of edges for the histogram for a specified number of bins. More...
 
QList< int > counts (int bins) const
 Returns the calculated list of the counts for the histogram bins. More...
 
double optimalBinWidth () const
 Calculates the optimal bin width using the Freedman-Diaconis rule. More...
 
int optimalNumberBins () const
 Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule. More...
 
void setValues (const QList< double > &values)
 Assigns numeric source values for the histogram. More...
 
bool setValues (QgsVectorLayer *layer, const QString &fieldOrExpression)
 Assigns numeric source values for the histogram from a vector layer's field or as the result of an expression. More...
 

Detailed Description

Calculator for a numeric histogram from a list of values.

Note
Added in version 2.9

Definition at line 33 of file qgshistogram.h.

Constructor & Destructor Documentation

QgsHistogram::QgsHistogram ( )

Definition at line 24 of file qgshistogram.cpp.

QgsHistogram::~QgsHistogram ( )
virtual

Definition at line 32 of file qgshistogram.cpp.

Member Function Documentation

QList< double > QgsHistogram::binEdges ( int  bins) const

Returns a list of edges for the histogram for a specified number of bins.

This list will be length bins + 1, as both the first and last value are also included.

Parameters
binsnumber of bins
Returns
list of bin edges
Note
values must first be specified using setValues

Definition at line 81 of file qgshistogram.cpp.

QList< int > QgsHistogram::counts ( int  bins) const

Returns the calculated list of the counts for the histogram bins.

Parameters
binsnumber of histogram bins
Returns
list of histogram counts
Note
values must first be specified using setValues

Definition at line 97 of file qgshistogram.cpp.

double QgsHistogram::optimalBinWidth ( ) const

Calculates the optimal bin width using the Freedman-Diaconis rule.

Bins widths are determined by the inter-quartile range of values and the number of values.

Returns
optimal width for bins
See also
optimalNumberBins
Note
values must first be specified using setValues

Definition at line 70 of file qgshistogram.cpp.

int QgsHistogram::optimalNumberBins ( ) const

Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule.

The number of bins are determined by the inter-quartile range of values and the number of values.

Returns
optimal number of bins
See also
optimalBinWidth
Note
values must first be specified using setValues

Definition at line 76 of file qgshistogram.cpp.

void QgsHistogram::setValues ( const QList< double > &  values)

Assigns numeric source values for the histogram.

Parameters
valueslist of doubles

Definition at line 49 of file qgshistogram.cpp.

bool QgsHistogram::setValues ( QgsVectorLayer layer,
const QString fieldOrExpression 
)

Assigns numeric source values for the histogram from a vector layer's field or as the result of an expression.

Parameters
layervector layer
fieldOrExpressionfield name or expression to be evaluated
Returns
true if values were successfully set

Definition at line 55 of file qgshistogram.cpp.


The documentation for this class was generated from the following files: